/** * @param RequestInterface $request A PSR-7 compatible Request instance. * @param ResponseInterface $response A PSR-7 compatible Response instance. * @return ResponseInterface * @todo This should be done via an Authenticator object. */ public function run(RequestInterface $request, ResponseInterface $response) { $user = User::getAuthenticated($this->modelFactory()); $res = $user->logout(); $this->setSuccess($res); return $response; }
/** * @param RequestInterface $request The request to initialize. * @return boolean */ public function init(RequestInterface $request) { $user = User::getAuthenticated($this->modelFactory()); if ($user) { $user->logout(); $this->deleteUserAuthTokens($user); } return parent::init($request); }
/** * Determine if the current user is authenticated. If not it redirects them to the login page. * * @return void */ private function auth() { if (!session_id()) { session_cache_limiter(false); session_start(); } $u = User::getAuthenticated(); if ($u === null || !$u->id()) { die('Auth required'); } }