use a better way to redirect to login if not authenticated
This commit is contained in:
parent
8473bc1930
commit
3d59043261
2 changed files with 3 additions and 5 deletions
|
@ -22,12 +22,12 @@ import vibe.web.web : errorDisplay, noRoute, redirect, render, SessionVar,
|
|||
|
||||
@requiresAuth class CalendarWebapp
|
||||
{
|
||||
@noRoute AuthInfo authenticate(scope HTTPServerRequest req, scope HTTPServerResponse res) @trusted
|
||||
@noRoute AuthInfo authenticate(scope HTTPServerRequest req, scope HTTPServerResponse res) @safe
|
||||
{
|
||||
if (!req.session || !req.session.isKeySet("auth"))
|
||||
{
|
||||
redirect("/login");
|
||||
throw new HTTPStatusException(HTTPStatus.forbidden, "Du musst dich erst einloggen");
|
||||
() @trusted{ redirect("/login"); }();
|
||||
return AuthInfo.init;
|
||||
}
|
||||
return req.session.get!AuthInfo("auth");
|
||||
}
|
||||
|
|
|
@ -8,5 +8,3 @@ html
|
|||
block navigation
|
||||
include navigation
|
||||
block content
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue