public function processChangePassword(Form $form) { $values = $form->getValues(); if ($this->user->email != $values['email']) { $this->flashMessage('<strong>Chyba!</strong> Vámi zadaný E-mail nesouhlasí s E-mailem, na který byl zaslán požadavek o změnu hesla!', 'error'); $this->redirect('this'); } try { $this->user->resetToken(); $this->user->password = $values['password']; $this->userManager->saveUser($this->user); } catch (\DibiException $e) { $this->flashMessage('<strong>Chyba!</strong> Při pokusu o změnu hesla došlo k chybě. Na nápravě se pracuje. Zkuste to prosím později.', 'error'); $this->redirect('this'); } $this->flashMessage('<strong>Úspěch!</strong> Heslo bylo změněno. Nyní se můžete přihlásit.', 'success'); $this->redirect('Account:default'); }
/** * * @param User $user * @return void */ public function resetToken(User $user) { $user->resetToken(); $this->userRepository->persist($user); }