2020-03-08 20:28:15 +00:00
|
|
|
from .template import WebpageController
|
2020-02-23 20:52:13 +00:00
|
|
|
from .session import SessionStorage
|
2020-02-23 18:23:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Authentication(object):
|
|
|
|
def isAuthenticated(self, request):
|
2020-02-23 20:52:13 +00:00
|
|
|
if "owrx-session" in request.cookies:
|
|
|
|
session = SessionStorage.getSharedInstance().getSession(request.cookies["owrx-session"].value)
|
|
|
|
return session is not None
|
2020-02-23 18:23:18 +00:00
|
|
|
return False
|
|
|
|
|
|
|
|
|
2020-03-08 20:28:15 +00:00
|
|
|
class AdminController(WebpageController):
|
2020-02-23 18:23:18 +00:00
|
|
|
def __init__(self, handler, request, options):
|
|
|
|
self.authentication = Authentication()
|
|
|
|
super().__init__(handler, request, options)
|
|
|
|
|
|
|
|
def handle_request(self):
|
|
|
|
if self.authentication.isAuthenticated(self.request):
|
|
|
|
super().handle_request()
|
|
|
|
else:
|
|
|
|
self.send_redirect("/login")
|