From 9e3fe7d5a5ce8aaccddb73fcb6253e7c8f35948f Mon Sep 17 00:00:00 2001 From: Pavel Loginov Date: Wed, 11 Sep 2019 09:05:57 +0300 Subject: [PATCH] v3.4.5.1 Login imporoved --- README.md | 2 +- app/login.py | 20 +++++++++++++++++--- app/templates/base.html | 6 +++--- app/templates/login.html | 10 +++++++++- inc/script.js | 34 ++++++++++++++++++++++++++-------- 5 files changed, 56 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index fe8adc54..4d0bb304 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Support the project [Demo video](https://www.youtube.com/channel/UCo0lCg24j-H4f0S9kMjp-_w) # Demo site -[Demo site](https://178.57.218.185) Login/password: admin/admin. Server resets every hour. +[Demo site](https://demo.haproxy-wi.org) Login/password: admin/admin. Server resets every hour. # Twitter Began to lead a [Twitter](https://twitter.com/haproxy_wi), subscribe! I will write there about all the changes and news diff --git a/app/login.py b/app/login.py index adb7207a..62597f8c 100644 --- a/app/login.py +++ b/app/login.py @@ -47,7 +47,18 @@ def send_cookie(login): print('ok') sys.exit() - + +def ban(): + c = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE")) + expires = datetime.datetime.utcnow() + datetime.timedelta(seconds=10) + c["ban"] = 1 + c["ban"]["path"] = "/app/" + c["ban"]["expires"] = expires.strftime("%a, %d %b %Y %H:%M:%S GMT") + print(c) + print("Content-type: text/html\n") + print('ban') + + def check_in_ldap(user, password): import ldap @@ -126,10 +137,13 @@ if login is not None and password is not None: else: if login in users[1] and password == users[3]: send_cookie(login) + break else: - print("Content-type: text/html\n") - print('
Your login or password is incorrect


') + ban() sys.exit() + else: + ban() + sys.exit() print("Content-type: text/html\n") if login is None: diff --git a/app/templates/base.html b/app/templates/base.html index 2c374633..799a807a 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -115,9 +115,9 @@ @@ -217,4 +217,4 @@
- \ No newline at end of file + diff --git a/app/templates/login.html b/app/templates/login.html index db619d96..e800c101 100644 --- a/app/templates/login.html +++ b/app/templates/login.html @@ -9,8 +9,16 @@



- + +