public function check($credentials) { $user = User::findFirstByEmail($credentials['email']); if (!$user) { $this->registerUserThrottling(0); throw new AuthException('Wrong email/password combination'); } if (!password_verify($credentials['password'], $user->passwordHash)) { $this->registerUserThrottling($user->id); throw new AuthException('Wrong email/password combination'); } // Check if the remember me was selected $remember = isset($credentials['remember']) ? true : false; $this->signIn($user, $remember); }
public function restorePasswordAction() { $form = new RestorePasswordForm(); if ($this->request->isPost()) { if ($form->isValid($this->request->getPost())) { $recipient = $this->request->getPost('email'); $user = User::findFirstByEmail($recipient); if ($user) { $code = $this->getRandomToken(true); $user->emailCode = $code; if ($user->save()) { $href = $this->url->getBaseUri() . 'new-password?id=' . $user->id . '&code=' . $code; $subject = 'Restore Password'; $body = 'Use the following link to change your password:<br>'; $body .= \Phalcon\Tag::linkTo($href, $href); $this->mail->send($recipient, $subject, $body); } } $this->flash->notice('A link with instructions on how to change an email was send to specified adress'); return $this->response->redirect('index'); } } $this->view->form = $form; }