diff options
author | Nico von Geyso <Nico.Geyso@FU-Berlin.de> | 2012-09-27 15:42:12 +0200 |
---|---|---|
committer | Nico von Geyso <Nico.Geyso@FU-Berlin.de> | 2012-09-27 15:42:55 +0200 |
commit | 032d19011fa57da582b0eb3ef9664588c34695f5 (patch) | |
tree | 6d52bc6bb81c0dea8bf715899b80c93fcd9c0fc6 | |
parent | 69f7c2e49fd9247111bee70b7afd56c104b1c984 (diff) | |
download | web-032d19011fa57da582b0eb3ef9664588c34695f5.tar.gz web-032d19011fa57da582b0eb3ef9664588c34695f5.tar.bz2 web-032d19011fa57da582b0eb3ef9664588c34695f5.zip |
redirect to settings if logged in
-rw-r--r-- | app.py | 17 | ||||
-rw-r--r-- | templates/index.html | 4 |
2 files changed, 10 insertions, 11 deletions
@@ -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 %} |