Login page
Bug fixed
pull/19/head
Aidaho12 7 years ago
parent f59eaa9b1e
commit c85f7003f0

@ -75,13 +75,12 @@ if login is not None and password is not None:
sql.write_user_uuid(login, user_uuid)
print("Content-type: text/html\n")
print('<html><head><title>Redirecting</title><meta charset="UTF-8">')
print('<link href="/style.css" rel="stylesheet">')
print('<meta http-equiv="refresh" content="0; url=%s">' % ref)
print('ok')
sys.exit()
print("Content-type: text/html\n")
print('<meta http-equiv="refresh" content="0; url=/app/login.py?error=1">')
print('<center><div class="alert alert-danger">Somthing wrong :( I\'m sad about this, but try again!</div><br /><br />')
sys.exit()
if login is None:
print("Content-type: text/html\n")

@ -190,7 +190,6 @@ if serv is not None and form.getvalue('rows') is not None:
if serv is not None and form.getvalue('rows1') is not None:
rows = form.getvalue('rows1')
grep = form.getvalue('grep')
grep = form.getvalue('grep')
hour = form.getvalue('hour')
minut = form.getvalue('minut')
hour1 = form.getvalue('hour1')
@ -280,7 +279,6 @@ if serv is not None and act == "configShow":
else:
cfg = hap_configs_dir + form.getvalue('configver')
print('<a name="top"></a>')
print("<center><h3>Config from %s</h3>" % serv)
print('<p class="accordion-expand-holder">'
'<a class="accordion-expand-all ui-button ui-widget ui-corner-all" href="#">Expand all</a>'

@ -1,14 +1,14 @@
{% extends "base.html" %}
{% block content %}
<center>
<form name="auth" action="login.py" class="form-horizontal" method="get">
<form name="auth" id="auth" action="login.py" class="form-horizontal" method="get">
{{error_log}}
{{error}}
{{db_create}}
<br>
<label for="login">Login: </label><input type="text" name="login" required class="form-control"><br /><br />
<label for="pass">Pass: </label><input type="password" name="pass" required class="form-control"><br /><br />
<input type="hidden" value="{{reff}}" name="ref">
<label for="login">Login: </label><input type="text" name="login" id="login" required class="form-control"><br /><br />
<label for="pass">Pass: </label><input type="password" name="pass" id="pass" required class="form-control"><br /><br />
<input type="hidden" value="{{reff}}" name="ref" id="ref">
<button type="submit" name="Login" value="Enter">Sign Up</button>
</form>
</center>

@ -7,13 +7,7 @@ from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/'))
template = env.get_template('viewstats.html')
form = cgi.FieldStorage()
serv = form.getvalue('serv')
if serv is None:
first_serv = sql.get_dick_permit()
for i in first_serv:
serv = i[2]
break
print('Content-type: text/html\n')
funct.check_login()
@ -22,14 +16,21 @@ try:
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
user_id = cookie.get('uuid')
user = sql.get_user_name_by_uuid(user_id.value)
role = sql.get_user_role_by_uuid(user_id.value)
servers = sql.get_dick_permit(virt=1)
if serv is None:
first_serv = sql.get_dick_permit()
for i in first_serv:
serv = i[2]
break
except:
pass
output_from_parsed_template = template.render(h2 = 1,
autorefresh = 1,
title = "HAProxy statistics",
role = sql.get_user_role_by_uuid(user_id.value),
role = role,
user = user,
onclick = "showStats()",
select_id = "serv",

@ -881,6 +881,32 @@ $( function() {
}
} );
});
$('#auth').submit(function() {
$('.alert-danger').remove();
let searchParams = new URLSearchParams(window.location.search)
if(searchParams.has('ref')) {
var ref = searchParams.get('ref');
} else {
var ref = "overview.py";
}
$.ajax( {
url: "login.py",
data: {
login: $('#login').val(),
pass: $('#pass').val()
},
type: "GET",
success: function( data ) {
if (data.indexOf('ok') != '-1') {
window.location.replace(ref);
} else {
$('.alert-danger').remove();
$("#ajax").html(data);
}
}
} );
return false;
});
});
function replace_text(id_textarea, text_var) {
var str = $(id_textarea).val();

Loading…
Cancel
Save