src/Auth/CookieAuthenticate.php
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;
    }
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;
    }
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 ; }
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.

@param Request $request The unused request object.
@return mixed False on login failure. An array of User data on success.
@throws \RuntimeException If CookieComponent is not loaded.
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 .