public function processSaveWholeName(Form $form, $values) { $user = $this->userManager->getUserByID($this->user->id); $user->name = $values['name']; $this->userManager->saveUser($user); $this->user->getIdentity()->name = $values['name']; $this->flashMessage('Vaše jméno bylo úspěšně změněno.', 'success'); $this->redirect('this'); }
/** * Performs an authentication against e.g. database. * and returns IIdentity on success or throws AuthenticationException * @return IIdentity * @throws AuthenticationException */ public function authenticate(array $credentials) { list($email, $password) = $credentials; try { $user = $this->userManager->findUserByEmail($email); } catch (\Exceptions\Runtime\UserNotFoundException $u) { throw new AuthenticationException('Zadali jste špatný email.'); } if (!Passwords::verify($password, $user->password)) { throw new AuthenticationException('Zadali jste špatné heslo.'); } elseif (Passwords::needsRehash($user->password)) { $user->password = Passwords::hash($password); $this->userManager->saveUser($user); } $info = array('lastLogin' => new \DateTime(), 'lastIP' => $this->httpRequest->getRemoteAddress()); $user->assign($info); $this->userManager->saveUser($user); $arr = $user->getData(); unset($arr['password']); return new Identity($user->userID, $user->role, $arr); }
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'); }