use fakeldap

This commit is contained in:
2026-05-14 19:09:41 +02:00
parent d78b096ffb
commit cf39ef9f4e
+7 -10
View File
@@ -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