diff --git a/app.py b/app.py index 8234abd..6aa6206 100644 --- a/app.py +++ b/app.py @@ -36,6 +36,16 @@ def login(): return render_template('index.html', ssh_port=config.webssh_port, machines=machines_all.machines, timezone=config.timezone) return render_template('login.html') +@app.route('/logout') +def logout(): + auth_token = request.cookies.get('auth_token') + if auth_token != "" or auth_token is not None: + if db.get_user_bytoken(auth_token) is not None: + db.del_auth_token(auth_token) + response = make_response(redirect('/')) + response.delete_cookie('auth_token') + return response + return render_template('login.html') @app.route('/create/conf') def create_conf(): diff --git a/db.py b/db.py index f041636..70d79f8 100644 --- a/db.py +++ b/db.py @@ -138,6 +138,18 @@ def add_auth_token(user_id): return token +def del_auth_token(token): + connect() + with get_cur() as cur: + cur.execute("DELETE FROM auth_tokens WHERE token = %s", (token, )) + try: + conn.commit() + return True + except: + return None + + + def login(username, password): user_id = get_user_pass(username, password) if user_id is not None: diff --git a/templates/index.html b/templates/index.html index 17e8897..e9d39bc 100644 --- a/templates/index.html +++ b/templates/index.html @@ -3,8 +3,84 @@ Panel administracyjny + +

Lista maszyn