Example #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->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');
 }
Example #3
0
 /**
  *
  *
  * @return \Talon\Models\Users\Users | bool
  * @throws AuthException
  */
 public function getUser()
 {
     $identity = $this->session->get(Auth::AUTH_ID_SESSION_KEY);
     if (isset($identity['id'])) {
         $user = Users::findFirstById($identity['id']);
         if ($user == false) {
             throw new AuthException(AuthException::USER_DOES_NOT_EXIST);
         }
         return $user;
     }
     return false;
 }
Example #4
0
 public function deleteAction($id, $sure = false)
 {
     if ($id) {
         $user = Users::findFirstById($id);
         if ($this->auth->getUser()->id === (int) $id) {
             $this->flashSession->error('You cannot delete yourself.');
         } elseif ($sure === 'yes') {
             /** @var \Talon\Models\Users\Users $user */
             $userName = $user->name;
             $user->delete();
             $this->flashSession->notice($userName . ' has been deleted.');
             return $this->redirect('users');
         } else {
             $this->flashSession->notice('The user was not deleted.');
         }
         return $this->redirect('users', 'edit/', array($id));
     }
     return $this->redirect('users');
 }