public function call() { $request = $this->app->request(); $response = $this->app->response(); $userName = $request->headers('PHP_AUTH_USER'); $password = $request->headers('PHP_AUTH_PW'); $user = new User(); if ($user->read($userName) && $user->isValid($password)) { $this->next->call(); return; } $response->status(401); $response->header('WWW-Authenticate', "Basic realm=\"{$this->realm}\""); }