Skip to content

Commit

Permalink
Add login code snippet for portal
Browse files Browse the repository at this point in the history
  • Loading branch information
- committed May 6, 2024
1 parent 600f3a7 commit 5581c20
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions web/portal/public/login_snippet.txt
Original file line number Diff line number Diff line change
@@ -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', '/'))

0 comments on commit 5581c20

Please sign in to comment.