示例#1
0
 /**
  * Call Sentry's check method or load of cached value.
  *
  * @return bool
  */
 public function check()
 {
     if ($this->cache === null) {
         $this->cache = $this->sentry->check();
     }
     return $this->cache && $this->getUser();
 }
示例#2
0
 /**
  * Check if a user is logged in and has the desired permissions
  *
  * @param string|array $permission One permission as string or several in an array to check against
  * @throws PermissionMissingException Throws an exception containing further information as message
  * @return bool Returns true if the logged in user has the required permissions
  */
 public function has($permission)
 {
     if (!$this->sentry->check()) {
         throw new PermissionMissingException('User is not logged in.');
     } else {
         $user = $this->sentry->getUser();
         if (!$user->hasAccess($permission)) {
             throw new PermissionMissingException('User is missing permissions.');
         }
         return true;
     }
 }
示例#3
0
 /**
  * Logout
  *
  * If you're actually logged in, it'll log you out and show a message.
  * Else it will silently redirect you to the login form.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function getLogout()
 {
     if ($this->sentry->check()) {
         $this->sentry->logout();
         $this->session->flash('success', 'You have successfully logged out.');
     }
     return $this->redirect->route('larapress.home.login.get');
 }
 /**
  * Check to see if the user is logged in and activated, and hasn't been banned or suspended.
  *
  * @return bool 
  * @static 
  */
 public static function check()
 {
     return \Cartalyst\Sentry\Sentry::check();
 }