From 5581c20ef36d5ca360eeb180f009ff6e4757e905 Mon Sep 17 00:00:00 2001 From: - <-@-> Date: Mon, 6 May 2024 20:32:39 +0300 Subject: [PATCH] Add login code snippet for portal --- web/portal/public/login_snippet.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 web/portal/public/login_snippet.txt diff --git a/web/portal/public/login_snippet.txt b/web/portal/public/login_snippet.txt new file mode 100644 index 0000000..a799c67 --- /dev/null +++ b/web/portal/public/login_snippet.txt @@ -0,0 +1,17 @@ +def login() -> Optional[RedirectResponse]: + def try_login() -> None: + pass_val = passwords.get(username.value.lower()) + authenticated = True + for i in range(len(pass_val)): + try: + if pass_val[i] == password.value[i]: + sleep(0.2) # Let the feeling sink in + else: + authenticated = False + ui.notify('Wrong username or password', color='negative') + except Exception: + authenticated = False + ui.notify('Wrong username or password', color='negative') + if authenticated: + app.storage.user.update({'username': username.value, 'authenticated': True}) + ui.navigate.to(app.storage.user.get('referrer_path', '/'))