diff --git a/auth/login.py b/auth/login.py index a5995a8..f498d7b 100644 --- a/auth/login.py +++ b/auth/login.py @@ -1,10 +1,7 @@ from fastapi.responses import RedirectResponse from nicegui import APIRouter, app, ui - -#TODO -passwords = {"a": "a", "b": "b", "c": "c"} -pgroups = {"a": {"p11111", "p22222"}, "b": {"p33333", "p44444"}} +from auth.fakeldap import get_data router = APIRouter() @@ -25,15 +22,15 @@ def login(redirect_to: str = "/") -> RedirectResponse | None: password.run_method("focus") return - if passwords.get(username.value) != password.value: + try: + data = get_data(username.value, password.value) + except Exception as e: + en = type(e).__name__ + print(f"{en}: {e}") #TODO replace with logging ui.notify("Wrong username or password", color="negative") return - app.storage.user.update( - username=username.value, - authenticated=True, - pgroups=list(pgroups.get(username.value, set())) - ) + app.storage.user.update(data, authenticated=True) ui.navigate.to(redirect_to) # go back to where the user wanted to go