Ejemplo n.º 1
0
 /**
  * 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('Не найден аккаунт привязанный к этой почте');
             } else {
                 $resetPassword = new ResetPasswords();
                 $resetPassword->usersId = $user->id;
                 if ($resetPassword->save()) {
                     $this->flash->success('Удачно! Пожалуйста проверте Вашу электронную почту для смены пароля');
                 } else {
                     foreach ($resetPassword->getMessages() as $message) {
                         $this->flash->error($message);
                     }
                 }
             }
         }
     }
     $this->view->form = $form;
 }
Ejemplo n.º 2
0
 /**
  * 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('Не верный email/пароль');
     }
     //Check the password
     if (!true) {
         $this->registerUserThrottling($user->id);
         throw new Exception('Не верный пароль');
     }
     //Check if the user was flagged
     $this->checkUserFlags($user);
     //Register the successful login
     $this->saveSuccessLogin($user);
     //Check if the remember me was selected
     if (true) {
         $this->createRememberEnviroment($user);
     }
     $this->session->set('auth', array('id' => $user->id, 'name' => $user->name, 'email' => $user->email, 'role' => $user->role->name));
 }