public function authenticate($credentials) { /** @var Users $user */ // Check if the user exist $user = Users::findFirstByEmail($credentials['email']); if ($user == false) { $this->registerFailedLogin(0); throw new AuthException(AuthException::CREDENTIALS_FAILED); } // Check the password if (!$this->security->checkHash($credentials['password'], $user->getPassword())) { $this->registerFailedLogin($user->id); throw new AuthException(AuthException::CREDENTIALS_FAILED); } // Check if the user is allowed $this->checkUserFlags($user); // Register the successful login $this->registerSuccessLogin($user); // Check if the remember me was selected if (isset($credentials['remember'])) { $this->createRememberTokens($user); } // authenticate the session $this->registerIdentity($user); }
/** * 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->flashSession->error($message); } } else { $user = Users::findFirstByEmail($this->request->getPost('email')); if (!$user) { $this->flashSession->error('There is no account associated with this email'); } else { $resetPassword = new ResetPasswords(); $resetPassword->usersId = $user->id; if ($resetPassword->save()) { $this->flashSession->success('Success! You have been sent an email with instructions on how to reset your password.'); return $this->redirect('session', 'login'); } else { foreach ($resetPassword->getMessages() as $message) { $this->flashSession->error($message); } } } } } $this->view->setVar('form', $form); }
public function resendConfirmationAction() { $email = $this->dispatcher->getParam('email'); /** @var \Talon\Models\Users\Users $user */ $user = Users::findFirstByEmail($email); if ($user->validated === 0) { if (!$user->sendConfirmation()) { foreach ($user->getMessages() as $message) { $this->flashSession->error($message); } } else { $this->flashSession->success('A confirmation email has been sent to your email address. You must confirm your email address before account access is granted.'); } } else { $this->flashSession->error('The email was not sent.'); } return $this->redirect('session', 'login'); }