From c85f7003f0469aa9dd9cc580cce017bb5ba6ca9f Mon Sep 17 00:00:00 2001 From: Aidaho12 Date: Thu, 31 May 2018 20:25:20 +0600 Subject: [PATCH] v2.5.5 Login page Bug fixed --- app/login.py | 7 +++---- app/options.py | 2 -- app/templates/login.html | 8 ++++---- app/viewsttats.py | 15 ++++++++------- inc/script.js | 26 ++++++++++++++++++++++++++ 5 files changed, 41 insertions(+), 17 deletions(-) diff --git a/app/login.py b/app/login.py index d4eb6a42..8e73aae6 100644 --- a/app/login.py +++ b/app/login.py @@ -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('Redirecting') - print('') - print('' % ref) + print('ok') sys.exit() print("Content-type: text/html\n") - print('') + print('
Somthing wrong :( I\'m sad about this, but try again!


') + sys.exit() if login is None: print("Content-type: text/html\n") diff --git a/app/options.py b/app/options.py index 01ffb8a3..3765c081 100644 --- a/app/options.py +++ b/app/options.py @@ -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('') print("

Config from %s

" % serv) print('

' 'Expand all' diff --git a/app/templates/login.html b/app/templates/login.html index c1e30f3b..6a16a158 100644 --- a/app/templates/login.html +++ b/app/templates/login.html @@ -1,14 +1,14 @@ {% extends "base.html" %} {% block content %}

-
+ {{error_log}} {{error}} {{db_create}}
-

-

- +

+

+
diff --git a/app/viewsttats.py b/app/viewsttats.py index 3c51d25e..875a5efd 100644 --- a/app/viewsttats.py +++ b/app/viewsttats.py @@ -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", diff --git a/inc/script.js b/inc/script.js index 82b73b70..e159826a 100644 --- a/inc/script.js +++ b/inc/script.js @@ -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();