FOC\Authenticate\Auth\CookieAuthenticate::getUser PHP Метод

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

Authenticates the identity contained in the cookie. Will use the userModel config, and fields config to find COOKIE data that is used to find a matching record in the model specified by userModel. Will return false if there is no cookie data, either username or password is missing, or if the scope conditions have not been met.
public getUser ( Cake\Network\Request $request ) : mixed
$request Cake\Network\Request The unused request object.
Результат mixed False on login failure. An array of User data on success.
    public function getUser(Request $request)
    {
        if (!isset($this->_registry->Cookie) || !$this->_registry->Cookie instanceof CookieComponent) {
            throw new \RuntimeException('CookieComponent is not loaded');
        }
        $cookieConfig = $this->_config['cookie'];
        $cookieName = $this->_config['cookie']['name'];
        unset($cookieConfig['name']);
        $this->_registry->Cookie->configKey($cookieName, $cookieConfig);
        $data = $this->_registry->Cookie->read($cookieName);
        if (empty($data)) {
            return false;
        }
        extract($this->_config['fields']);
        if (empty($data[$username]) || empty($data[$password])) {
            return false;
        }
        $user = $this->_findUser($data[$username], $data[$password]);
        if ($user) {
            $request->session()->write($this->_registry->Auth->sessionKey, $user);
            return $user;
        }
        return false;
    }