示例#1
0
 /**
  * Checks to see if a user is logged in.
  *
  * @return \Cartalyst\Sentinel\Users\UserInterface|bool
  */
 public function check()
 {
     if ($this->user !== null) {
         return $this->user;
     }
     if (!($code = $this->persistences->check())) {
         return false;
     }
     if (!($user = $this->persistences->findUserByPersistenceCode($code))) {
         return false;
     }
     if (!$this->cycleCheckpoints('check', $user)) {
         return false;
     }
     return $this->user = $user;
 }
示例#2
0
 /**
  * Logs the current user out.
  *
  * @param  \Cartalyst\Sentinel\Users\UserInterface  $user
  * @param  bool  $everywhere
  * @return bool
  */
 public function logout(UserInterface $user = null, $everywhere = false)
 {
     $currentUser = $this->check();
     if ($user && $user !== $currentUser) {
         $this->persistences->flush($user, false);
         return true;
     }
     $user = $user ?: $currentUser;
     if ($user === false) {
         return true;
     }
     $method = $everywhere === true ? 'flush' : 'forget';
     $this->persistences->{$method}($user);
     $this->user = null;
     return $this->users->recordLogout($user);
 }