+ //Render view
+ return $this->render(
+ //Template
+ $this->config['login']['view']['name'],
+ //Context
+ ['login' => $login->createView(), 'disabled' => $request->query->get('disabled', 0), 'sent' => $request->query->get('sent', 0)]+$context+$this->config['login']['view']['context']
+ );
+ }
+
+ /**
+ * Recover account
+ *
+ * @param Request $request The request
+ * @param ?string $hash The hashed password
+ * @param ?string $pass The shorted password
+ * @param ?string $mail The shorted mail address
+ * @return Response The response
+ */
+ public function recover(Request $request, ?string $hash, ?string $pass, ?string $mail): Response {
+ //Set user
+ $user = null;
+
+ //Set context
+ $context = [];
+
+ //With mail, pass and hash
+ if (!empty($mail) && !empty($pass) && !empty($hash)) {
+ //With invalid hash
+ if ($hash != $this->slugger->hash($mail.$pass)) {
+ //Throw bad request
+ throw new BadRequestHttpException($this->translator->trans('Invalid %field% field: %value%', ['%field%' => 'hash', '%value%' => $hash]));
+ }
+
+ //Get mail
+ $mail = $this->slugger->unshort($smail = $mail);
+
+ //Without valid mail
+ if (filter_var($mail, FILTER_VALIDATE_EMAIL) === false) {
+ //Throw bad request
+ //XXX: prevent slugger reverse engineering by not displaying decoded mail
+ throw new BadRequestHttpException($this->translator->trans('Invalid %field% field: %value%', ['%field%' => 'mail', '%value%' => $smail]));
+ }
+
+ //With existing subscriber
+ if (empty($user = $this->doctrine->getRepository($this->config['class']['user'])->findOneByMail($mail))) {
+ //Throw not found
+ //XXX: prevent slugger reverse engineering by not displaying decoded mail
+ throw $this->createNotFoundException($this->translator->trans('Unable to find account %mail%', ['%mail%' => $smail]));
+ }
+
+ //With unmatched pass
+ if ($pass != $this->slugger->hash($user->getPassword())) {
+ //Throw not found
+ //XXX: prevent use of outdated recover link
+ throw $this->createNotFoundException($this->translator->trans('Outdated recover link'));
+ }
+
+ //Set context
+ $context = ['mail' => $smail, 'pass' => $pass, 'hash' => $hash];
+ }
+
+ //Create the LoginType form and give the proper parameters
+ $form = $this->createForm($this->config['recover']['view']['form'], $user, [
+ //Set action to recover route name and context
+ 'action' => $this->generateUrl($this->config['route']['recover']['name'], $context+$this->config['route']['recover']['context']),
+ //With user disable mail
+ 'mail' => ($user === null),
+ //With user enable password
+ 'password' => ($user !== null),
+ //Set method
+ 'method' => 'POST'
+ ]);
+
+ //With post method
+ if ($request->isMethod('POST')) {
+ //Refill the fields in case the form is not valid.
+ $form->handleRequest($request);
+
+ //With form submitted and valid
+ if ($form->isSubmitted() && $form->isValid()) {
+ //Set data
+ $data = $form->getData();
+
+ //With user
+ if ($user !== null) {
+ //Set hashed password
+ $hashed = $this->hasher->hashPassword($user, $user->getPassword());
+
+ //Update pass
+ $pass = $this->slugger->hash($hashed);
+
+ //Set user password
+ $user->setPassword($hashed);