-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.py
31 lines (28 loc) · 1.37 KB
/
login.py
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
29
30
31
import central as c
import messages as m
from html_template import html_template_start, html_template_end
from components import select_row
import languages as l
def is_user_logged(user):
if user == "Anonymous":
m.add_message(_('Login required.'))
return False
return True
def check_security(username, password):
if username == c.ADMIN and password == c.ADMIN_PASSWORD:
return True
if username != '' and username == c.read_app_config_value('username') and password != '' and password == c.read_app_config_value('password'):
return True
return False
def login_html():
html = html_template_start('/login', c.read_app_config_value('title'), c.read_config_value('firmware_version'), _('Identification'))
html += '<form action="/login_submit" method="post" class="text_align_center">' + c.CR
html += '<br/><div><input type="text" placeholder="' + _('Username') + '" name="username"/></div><br/>' + c.CR
html += '<div><input type="password" placeholder="' + _('Password') + '" name="password"/></div>' + c.CR
html += '<br/>' + c.CR
html += '<table style="margin:0 auto;">' + select_row(_('Interface language'), 'language', c.read_app_config_value('language'), '', l.LANGUAGES) + '</table>' + c.CR
html += '<br/>' + c.CR
html += '<input type="submit" value="' + _('Log in') + '"/>' + c.CR
html += '</form>' + c.CR
html += html_template_end()
return html