notAuthenticated method
Renders errors.404 template or plain 404.
Implementation
HttpResponse notAuthenticated() {
final engine = App().container.make<TemplateEngine>();
try {
final html = engine.render("errors.401", {});
response.headers.contentType = ContentType.html;
final cookie = Cookie('archery_csrf_token', App.generateKey())
..httpOnly = true
..secure = true
..sameSite = SameSite.lax;
return response
..statusCode = HttpStatus.unauthorized
..cookies.add(cookie)
..write(html)
..close();
} catch (e) {
return response
..statusCode = HttpStatus.unauthorized
..write("401 Unauthenticated")
..close();
}
}