implement redirect on login

This commit is contained in:
Jakob Ketterl 2020-04-26 01:54:48 +02:00
parent 9942b3baf2
commit 5282b5f8df
2 changed files with 9 additions and 3 deletions

View File

@ -1,6 +1,11 @@
from .template import WebpageController
from .session import SessionStorage
from owrx.config import Config
from urllib import parse
import logging
logger = logging.getLogger(__name__)
class Authentication(object):
@ -24,4 +29,5 @@ class AdminController(WebpageController):
if self.authentication.isAuthenticated(self.request):
super().handle_request()
else:
self.send_redirect("/login")
target = "/login?{0}".format(parse.urlencode({"ref": self.request.path}))
self.send_redirect(target)

View File

@ -50,8 +50,8 @@ class SessionController(WebpageController):
key = SessionStorage.getSharedInstance().startSession({"user": user.name})
cookie = SimpleCookie()
cookie["owrx-session"] = key
# TODO pass the final destination
self.send_redirect("/settings", cookies=cookie)
target = self.request.query["ref"][0] if "ref" in self.request.query else "/settings"
self.send_redirect(target, cookies=cookie)
return
self.send_redirect("/login")