fix guards

This commit is contained in:
David Rodenkirchen 2024-11-27 12:24:49 +01:00
parent 1a33ea69f2
commit 4706183bde

View File

@ -1,16 +1,16 @@
from typing import Optional
from rio import Session, URL
from rio import Session, URL, GuardEvent
from src.ez_lan_manager.types.SessionStorage import SessionStorage
# Guards pages against access from users that are NOT logged in
def logged_in_guard(session: Session, _) -> Optional[URL]:
if session[SessionStorage].user_id is None:
def logged_in_guard(event: GuardEvent) -> Optional[URL]:
if event.session[SessionStorage].user_id is None:
return URL("./")
# Guards pages against access from users that ARE logged in
def not_logged_in_guard(session: Session, _) -> Optional[URL]:
if session[SessionStorage].user_id is not None:
def not_logged_in_guard(event: GuardEvent) -> Optional[URL]:
if event.session[SessionStorage].user_id is not None:
return URL("./")