/** * Checks the user credentials. * * @param array $credentials * * @return bool */ public function check($credentials) { $user = User::findFirstByEmail(strtolower($credentials['email'])); if ($user == false) { $this->registerUserThrottling(null); throw new Exception('Wrong email/password combination'); } if (!$this->security->checkHash($credentials['password'], $user->getPassword())) { $this->registerUserThrottling($user->getId()); throw new Exception('Wrong email/password combination'); } $this->checkUserFlags($user); $this->saveSuccessLogin($user); if (isset($credentials['remember'])) { $this->createRememberEnviroment($user); } $this->setIdentity($user); }
/** * Shows the forgot password form */ public function forgotPasswordAction() { $form = new ForgotPasswordForm(); if ($this->request->isPost()) { if (!$form->isValid($this->request->getPost())) { foreach ($form->getMessages() as $message) { $this->flash->error($message); } } else { $email = trim(strtolower($this->request->getPost('email'))); $user = User::findFirstByEmail($email); if (!$user) { $this->flash->error('There is no account associated to this email'); } else { $resetPassword = new UserResetPasswords(); $resetPassword->setUserId($user->getId()); if ($resetPassword->save()) { $this->flashSession->success('Success! Please check your messages for an email reset password'); $this->view->disable(); return $this->response->redirect($this->_activeLanguage . '/user/forgotPassword'); } else { foreach ($resetPassword->getMessages() as $message) { $this->flash->error($message); } } } } } $this->view->form = $form; }