/** * Logs the user out and redirects to the login page * * @param Psr\Http\Message\ServerRequestInterface $request * @param Psr\Http\Message\ResponseInterface $response * @param array $args */ public function destroy($request, $response, $args) { $this->authentication->logout(); $this->resetContextValues(); $this->context['user'] = null; // Redirect to the login page return $response->withStatus(301)->withHeader('Location', '/login'); }