Warning: Undefined variable $namespace in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 3
;
use
Warning: Undefined variable $token_full_class_name in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 5
;
use
Warning: Undefined variable $user_full_class_name in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 6
;
use
Warning: Undefined variable $request_form_full_class_name in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 7
;
use
Warning: Undefined variable $resetting_form_full_class_name in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 8
;
use Symfony\Bundle\FrameworkBundle\Controller\
Warning: Undefined variable $parent_class_name in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 9
;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
/**
* @Route("/forgotten-password")
*/
class
Warning: Undefined variable $class_name in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 19
extends
Warning: Undefined variable $parent_class_name in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 19
{
private const SESSION_TOKEN_KEY = 'forgotten_password_token';
private const SESSION_CAN_CHECK_EMAIL = 'forgotten_password_check_email';
/**
* @Route("/request", name="app_forgotten_password_request")
*/
public function request(Request $request, \Swift_Mailer $mailer): Response
{
$form = $this->createForm(
Warning: Undefined variable $request_form_class_name in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 29
::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$user = $this->getDoctrine()->getRepository(
Warning: Undefined variable $user_class_name in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 33
::class)->findOneBy([
'
Warning: Undefined variable $email_field in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 34
' => $form->get('
Warning: Undefined variable $email_field in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 34
')->getData(),
]);
// Needed to be able to access next page, app_check_email
$request->getSession()->set(self::SESSION_CAN_CHECK_EMAIL, true);
// Do not reveal whether an user account was found or not.
if (!$user) {
return $this->redirectToRoute('app_check_email');
}
// If User already has a valid Token, we don't want to generate a new one.
// We fail silently.
$oldTokens = $this->getDoctrine()->getRepository(
Warning: Undefined variable $token_class_name in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 47
::class)->findNonExpiredForUser($user);
if (count($oldTokens)) {
return $this->redirectToRoute('app_check_email');
}
// Generate a reset password token, that the user could use to change their password.
$resetPasswordToken = new
Warning: Undefined variable $token_class_name in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 53
($user);
$this->getDoctrine()->getManager()->persist($resetPasswordToken);
$this->getDoctrine()->getManager()->flush();
$message = (new \Swift_Message('Your password reset request'))
->setFrom(['noreply@mydomain.com' => 'Noreply'])
->setTo($user->
Warning: Undefined variable $email_getter in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 59
())
->setBody($this->renderView('forgotten_password/email.txt.twig', [
'token' => $resetPasswordToken,
]))
;
$mailer->send($message);
return $this->redirectToRoute('app_check_email');
}
return $this->render('forgotten_password/request.html.twig', [
'requestForm' => $form->createView(),
]);
}
/**
* @Route("/check-email", name="app_check_email")
*/
public function checkEmail(SessionInterface $session)
{
// We prevent users from directly accessing this page
if (!$session->get(self::SESSION_CAN_CHECK_EMAIL)) {
return $this->redirectToRoute('app_forgotten_password_request');
}
$session->remove(self::SESSION_CAN_CHECK_EMAIL);
return $this->render('forgotten_password/check_email.html.twig', [
'tokenLifetime' =>
Warning: Undefined variable $token_class_name in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 87
::LIFETIME_HOURS,
]);
}
/**
* @Route("/reset/{tokenAndSelector}", name="app_reset_password")
*/
public function reset(Request $request, UserPasswordEncoderInterface $passwordEncoder, $tokenAndSelector = null): Response
{
if ($tokenAndSelector) {
// We store token in session and remove it from the URL,
// to avoid any leak if someone get to know the URL (AJAX requests, Analytics...).
$request->getSession()->set(self::SESSION_TOKEN_KEY, $tokenAndSelector);
return $this->redirectToRoute('app_reset_password');
}
$tokenAndSelector = $request->getSession()->get(self::SESSION_TOKEN_KEY);
if (!$tokenAndSelector) {
throw $this->createNotFoundException();
}
$passwordResetToken = $this->getDoctrine()->getRepository(
Warning: Undefined variable $token_class_name in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 109
::class)->findOneBy([
'selector' => substr($tokenAndSelector, 0,
Warning: Undefined variable $token_class_name in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 110
::SELECTOR_LENGTH),
]);
if (!$passwordResetToken) {
throw $this->createNotFoundException();
}
if ($passwordResetToken->isExpired() || !$passwordResetToken->isTokenEquals(substr($tokenAndSelector,
Warning: Undefined variable $token_class_name in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 117
::SELECTOR_LENGTH))) {
$this->getDoctrine()->getManager()->remove($passwordResetToken);
$this->getDoctrine()->getManager()->flush();
throw $this->createNotFoundException();
}
$form = $this->createForm(
Warning: Undefined variable $resetting_form_class_name in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 124
::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
// A
Warning: Undefined variable $token_class_name in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 128
should be used only once, remove it.
$this->getDoctrine()->getManager()->remove($passwordResetToken);
// Encode the plain password, and set it.
$passwordResetToken->getUser()->
Warning: Undefined variable $password_setter in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 132
(
$passwordEncoder->encodePassword(
$passwordResetToken->getUser(),
$form->get('plainPassword')->getData()
)
);
$this->getDoctrine()->getManager()->flush();
// TODO: please check the login route
return $this->redirectToRoute('
Warning: Undefined variable $login_route in /home/net1/social.net1.club/vendor/symfony/maker-bundle/src/Resources/skeleton/forgottenPassword/ForgottenPasswordController.tpl.php on line 142
');
}
return $this->render('forgotten_password/reset.html.twig', [
'resetForm' => $form->createView(),
]);
}
}