Tweak the login page

This commit is contained in:
Thomas Sileo 2018-07-15 21:25:09 +02:00
parent e3284416d2
commit 5323995633
3 changed files with 17 additions and 4 deletions

3
app.py
View file

@ -471,6 +471,9 @@ def admin_logout():
@app.route("/login", methods=["POST", "GET"]) @app.route("/login", methods=["POST", "GET"])
def admin_login(): def admin_login():
if session.get("logged_in") is True:
return redirect(url_for("admin_notifications"))
devices = [doc["device"] for doc in DB.u2f.find()] devices = [doc["device"] for doc in DB.u2f.find()]
u2f_enabled = True if devices else False u2f_enabled = True if devices else False
if request.method == "POST": if request.method == "POST":

View file

@ -12,6 +12,7 @@
{% block links %}{% endblock %} {% block links %}{% endblock %}
{% if config.THEME_COLOR %}<meta name="theme-color" content="{{ config.THEME_COLOR }}">{% endif %} {% if config.THEME_COLOR %}<meta name="theme-color" content="{{ config.THEME_COLOR }}">{% endif %}
<style>{{ config.CSS | safe }}</style> <style>{{ config.CSS | safe }}</style>
{% block headers %}{% endblock %}
</head> </head>
<body> <body>
{% if logged_in %} {% if logged_in %}
@ -20,7 +21,7 @@
<li class="left"><a href="/admin/new"{% if request.path == "/admin/new" %} class="selected" {% endif %}>New</a></li> <li class="left"><a href="/admin/new"{% if request.path == "/admin/new" %} class="selected" {% endif %}>New</a></li>
<li class="left"><a href="/admin/stream"{% if request.path == "/admin/stream" %} class="selected" {% endif %}>Stream</a></li> <li class="left"><a href="/admin/stream"{% if request.path == "/admin/stream" %} class="selected" {% endif %}>Stream</a></li>
<li class="left"><a href="/admin/notifications"{% if request.path == "/admin/notifications" %} class="selected" {% endif %}>Notifications</a></li> <li class="left"><a href="/admin/notifications"{% if request.path == "/admin/notifications" %} class="selected" {% endif %}>Notifications</a></li>
<li class="right"><a href="/admin/logout">Logout</a></li> <li class="left"><a href="/admin/logout">Logout</a></li>
</ul> </ul>
{% endif %} {% endif %}

View file

@ -1,11 +1,20 @@
{% extends "layout.html" %} {% extends "layout.html" %}
{% import 'utils.html' as utils %} {% import 'utils.html' as utils %}
{% block title %}Login - {{ config.NAME }}{% endblock %} {% block title %}Login - {{ config.NAME }}{% endblock %}
{% block header %} {% block headers %}
<style>
#login-container {
height: 90%;
display: grid;
}
#login-form {
margin:auto;
display:inline;
}
</style>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div id="container"> <div id="login-container">
{% if session.logged_in %}logged{% else%}not logged{%endif%}
<form id="login-form" method="POST"> <form id="login-form" method="POST">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/> <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>