mirror of https://github.com/Aidaho12/haproxy-wi
login
parent
aab03e46fc
commit
563df38f3c
|
@ -11,9 +11,7 @@ form = cgi.FieldStorage()
|
||||||
ref = form.getvalue('ref')
|
ref = form.getvalue('ref')
|
||||||
login = form.getvalue('login')
|
login = form.getvalue('login')
|
||||||
password = form.getvalue('pass')
|
password = form.getvalue('pass')
|
||||||
USERS = 'cgi-bin/users'
|
USERS = '/var/www/haproxy-wi/cgi-bin/users'
|
||||||
|
|
||||||
funct.check_login()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(USERS, "r") as user:
|
with open(USERS, "r") as user:
|
||||||
|
@ -46,6 +44,7 @@ if form.getvalue('logout') is not None:
|
||||||
print("Set-cookie: FirstName=; expires=Wed May 18 03:33:20 2003; path=/cgi-bin/; httponly")
|
print("Set-cookie: FirstName=; expires=Wed May 18 03:33:20 2003; path=/cgi-bin/; httponly")
|
||||||
print("Set-cookie: LastName=; expires=Wed May 18 03:33:20 2003; path=/cgi-bin/; httponly")
|
print("Set-cookie: LastName=; expires=Wed May 18 03:33:20 2003; path=/cgi-bin/; httponly")
|
||||||
print("Set-cookie: role=; expires=Wed May 18 03:33:20 2003; path=/cgi-bin/; httponly")
|
print("Set-cookie: role=; expires=Wed May 18 03:33:20 2003; path=/cgi-bin/; httponly")
|
||||||
|
print("Content-type: text/html\n")
|
||||||
print('<meta http-equiv="refresh" content="0; url=/">')
|
print('<meta http-equiv="refresh" content="0; url=/">')
|
||||||
|
|
||||||
if login is None:
|
if login is None:
|
||||||
|
@ -54,12 +53,21 @@ if login is None:
|
||||||
if login is not None and password is not None:
|
if login is not None and password is not None:
|
||||||
for f in open(USERS, 'r'):
|
for f in open(USERS, 'r'):
|
||||||
users = json.loads(f)
|
users = json.loads(f)
|
||||||
print(users['login'])
|
|
||||||
if login in users['login'] and password == users['password']:
|
if login in users['login'] and password == users['password']:
|
||||||
print("Set-cookie: login=%s; expires=Wed May 18 03:33:20 2033; path=/cgi-bin/; httponly" % login)
|
c = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||||
print("Set-cookie: FirstName=%s; expires=Wed May 18 03:33:20 2033; path=/cgi-bin/; httponly" % users['firstName'])
|
c["login"] = login
|
||||||
print("Set-cookie: LastName=%s; expires=Wed May 18 03:33:20 2033; path=/cgi-bin/; httponly" % users['lastName'])
|
c["login"]["path"] = "/cgi-bin/"
|
||||||
print("Set-cookie: role=%s; expires=Wed May 18 03:33:20 2033; path=/cgi-bin/; httponly" % users['role'])
|
c["login"]["expires"] = "Wed May 18 03:33:20 2033"
|
||||||
|
c["FirstName"] = users['firstName']
|
||||||
|
c["FirstName"]["path"] = "/cgi-bin/"
|
||||||
|
c["FirstName"]["expires"] = "Wed May 18 03:33:20 2033"
|
||||||
|
c["LastName"] = users['lastName']
|
||||||
|
c["LastName"]["path"] = "/cgi-bin/"
|
||||||
|
c["LastName"]["expires"] = "Wed May 18 03:33:20 2033"
|
||||||
|
c["role"] = users['role']
|
||||||
|
c["role"]["path"] = "/cgi-bin/"
|
||||||
|
c["role"]["expires"] = "Wed May 18 03:33:20 2033"
|
||||||
|
print(c)
|
||||||
if form.getvalue('ref') is None:
|
if form.getvalue('ref') is None:
|
||||||
ref = "/index.html"
|
ref = "/index.html"
|
||||||
print("Content-type: text/html\n")
|
print("Content-type: text/html\n")
|
||||||
|
@ -70,6 +78,3 @@ if login is not None and password is not None:
|
||||||
login_page("error")
|
login_page("error")
|
||||||
|
|
||||||
funct.footer()
|
funct.footer()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue