Example #1
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 #2
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');
 }