/** * Shows the forgot password form */ public function forgotPasswordAction() { $form = new ForgotPasswordForm(); if ($this->request->isPost()) { if ($form->isValid($this->request->getPost()) == false) { foreach ($form->getMessages() as $message) { $this->flash->error($message); } } else { $user = Users::findFirstByEmail($this->request->getPost('email')); if (!$user) { $this->flash->success('There is no account associated to this email'); } else { $resetPassword = new ResetPasswords(); $resetPassword->usersId = $user->id; if ($resetPassword->save()) { $this->flash->success('Success! Please check your messages for an email reset password'); } else { foreach ($resetPassword->getMessages() as $message) { $this->flash->error($message); } } } } } $this->view->form = $form; }
/** * Checks the user credentials * * @param array $credentials * @return boolan */ public function check($credentials) { // Check if the user exist $user = Users::findFirstByEmail($credentials['email']); if ($user == false) { $this->registerUserThrottling(0); throw new Exception('Wrong email/password combination'); } // Check the password if (!$this->security->checkHash($credentials['password'], $user->password)) { $this->registerUserThrottling($user->id); throw new Exception('Wrong email/password combination'); } // Check if the user was flagged $this->checkUserFlags($user); // Register the successful login $this->saveSuccessLogin($user); // Check if the remember me was selected if (isset($credentials['remember'])) { $this->createRememberEnviroment($user); } $this->session->set('auth-identity', array('id' => $user->id, 'name' => $user->name, 'profile' => $user->profile->name)); }