simpler focus; the default None is falsey anyway
This commit is contained in:
+3
-8
@@ -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
@@ -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")
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user