-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.py
More file actions
executable file
·28 lines (25 loc) · 1.02 KB
/
index.py
File metadata and controls
executable file
·28 lines (25 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/python3
from python.webpage_functions import print_html, get_form_data, has_form_data, print_main, get_user, set_cookie
from python.htmlGenerators import viewProducts, nav
from python.password import Password
from python.login import tryLogIn
# Either show login page or landing page
if not get_user().logged_in:
if has_form_data():
# Page loading with incoming form data
# Try to log in with the data
login_id, password = get_form_data("id"), Password(get_form_data("password"))
logInCookie = tryLogIn(login_id, password)
if logInCookie:
# successful
set_cookie(logInCookie)
# print the main dashboard
print_main(viewProducts.create_table_of_locations())
else:
# unsuccessful - print login page with error message
print_html('login.html') #### Error message?
else:
# No data - Print log in page
print_html('login.html')
else:
print_main(viewProducts.create_table_of_locations())