Cartalyst\Sentinel\Sentinel::check PHP Метод

check() публичный Метод

Checks to see if a user is logged in.
public check ( ) : Cartalyst\Sentinel\Users\UserInterface | boolean
Результат Cartalyst\Sentinel\Users\UserInterface | boolean
    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;
    }

Usage Example

Пример #1
0
 public function getLogout()
 {
     try {
         if (!!($user = $this->sentinel->check())) {
             $this->setResponseData($this->sentinel->logout(null, true));
         } else {
             throw new \Exception("Can't get current user");
         }
     } catch (\Exception $e) {
         $this->setErrorData($e->getMessage());
     }
     return $this->responseJson();
 }
All Usage Examples Of Cartalyst\Sentinel\Sentinel::check