simpler focus; the default None is falsey anyway

This commit is contained in:
2026-05-12 11:30:58 +02:00
parent 0ce457249b
commit cc8b436db4
2 changed files with 4 additions and 9 deletions
+3 -8
View File
@@ -12,17 +12,17 @@ router = APIRouter()
@router.page("/login")
def login(redirect_to: str = "/") -> RedirectResponse | None:
if app.storage.user.get("authenticated", False):
if app.storage.user.get("authenticated"):
return RedirectResponse("/")
def try_login(): # local function to avoid passing username and password as arguments
if not username.value:
ui.notify("Missing username", color="negative")
focus(username)
username.run_method("focus")
return
if not password.value:
focus(password)
password.run_method("focus")
return
if passwords.get(username.value) != password.value:
@@ -49,8 +49,3 @@ def login(redirect_to: str = "/") -> RedirectResponse | None:
def focus(element):
ui.run_javascript(f"getElement({element.id}).$refs.qRef.focus()")
+1 -1
View File
@@ -17,7 +17,7 @@ class AuthMiddleware(BaseHTTPMiddleware):
path = request.url.path
if (
app.storage.user.get("authenticated", False)
app.storage.user.get("authenticated")
or path in unrestricted_page_routes
or path.startswith("/_nicegui")
):