Skip to content

[reset-password] fix missing entity manager di #1017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ class <?= $class_name ?> extends AbstractController
use ResetPasswordControllerTrait;

private $resetPasswordHelper;
private $entityManager;

public function __construct(ResetPasswordHelperInterface $resetPasswordHelper)
public function __construct(ResetPasswordHelperInterface $resetPasswordHelper, EntityManagerInterface $entityManager)
{
$this->resetPasswordHelper = $resetPasswordHelper;
$this->entityManager = $entityManager;
}

/**
Expand Down Expand Up @@ -82,7 +84,7 @@ public function checkEmail(): Response
* @Route("/reset/{token}", name="app_reset_password")
*/
<?php } ?>
public function reset(Request $request, <?= $password_hasher_class_details->getShortName() ?> <?= $password_hasher_variable_name ?>, EntityManagerInterface $entityManager, string $token = null): Response
public function reset(Request $request, <?= $password_hasher_class_details->getShortName() ?> <?= $password_hasher_variable_name ?>, string $token = null): Response
{
if ($token) {
// We store the token in session and remove it from the URL, to avoid the URL being
Expand Down Expand Up @@ -123,7 +125,7 @@ public function reset(Request $request, <?= $password_hasher_class_details->getS
);

$user-><?= $password_setter ?>($encodedPassword);
$entityManager->flush();
$this->entityManager->flush();

// The session is cleaned up after the password has been changed.
$this->cleanSessionAfterReset();
Expand All @@ -136,9 +138,9 @@ public function reset(Request $request, <?= $password_hasher_class_details->getS
]);
}

private function processSendingPasswordResetEmail(string $emailFormData, MailerInterface $mailer, EntityManagerInterface $entityManager): RedirectResponse
private function processSendingPasswordResetEmail(string $emailFormData, MailerInterface $mailer): RedirectResponse
{
$user = $entityManager->getRepository(<?= $user_class_name ?>::class)->findOneBy([
$user = $this->entityManager->getRepository(<?= $user_class_name ?>::class)->findOneBy([
'<?= $email_field ?>' => $emailFormData,
]);

Expand Down