public function user($key = null)
    {
        $user = $this->storage()->read();
        if (!$user) {
            return null;
        }

        if ($key === null) {
            return $user;
        }

        return Hash::get($user, $key);
    }
public function user($key = null)
    {
        $user = $this->storage()->read();
        if (!$user) {
            return null;
        }

        if ($key === null) {
            return $user;
        }

        return Hash::get($user, $key);
    }
public function user ( $ key = null ) { $ user = $ this -> storage ( ) -> read ( ) ; if ( ! $ user ) { return null ; } if ( $ key === null ) { return $ user ; } return Hash :: get ( $ user , $ key ) ; }
Get the current user from storage.

@param string|null $key Field to retrieve. Leave null to get entire User record.
@return mixed|null Either User record or null if no user is logged in, or retrieved field if key is specified.
@link https://book.cakephp.org/3.0/en/controllers/components/authentication.html#accessing-the-logged-in-user
Get the current user from storage .