summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app.py17
-rw-r--r--templates/index.html4
2 files changed, 10 insertions, 11 deletions
diff --git a/app.py b/app.py
index 3785ac8..3b4c202 100644
--- a/app.py
+++ b/app.py
@@ -47,13 +47,16 @@ def read_blacklist():
@app.route('/', methods=['GET', 'POST'])
@templated('index.html')
def index():
- form = LoginForm(request.form)
- if request.method == 'POST' and form.validate():
- if login_user(form.username.data, form.password.data):
- flash(u'Erfolgreich eingeloggt', 'success')
- return redirect(url_for('settings'))
- else:
- flash(u'Ungültiger Benutzername und/oder Passwort', 'error')
+ if not g.user:
+ form = LoginForm(request.form)
+ if request.method == 'POST' and form.validate():
+ if login_user(form.username.data, form.password.data):
+ flash(u'Erfolgreich eingeloggt', 'success')
+ return redirect(url_for('settings'))
+ else:
+ flash(u'Ungültiger Benutzername und/oder Passwort', 'error')
+ else:
+ return redirect(url_for('settings'))
return {'form': form}
diff --git a/templates/index.html b/templates/index.html
index 6fae303..3e192e5 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -2,9 +2,6 @@
{%- from '_macros.html' import render_field %}
{%- block content %}
-{%- if g.user %}
-<p>Hallo {{ session.username }}. <a href="{{ url_for('settings') }}">Einstellungen</a></p>
-{%- else %}
<form action="{{ url_for('index') }}" method="post" class="form-horizontal">
<h2>Login</h2>
<p>
@@ -20,6 +17,5 @@
<p class="form-actions"><a href="/register">Account erstellen</a></div>
<p class="form-actions"><a href="/lost_password">Passwort vergessen</a></div>
</form>
-{%- endif %}
{%- endblock %}