login: Handle next properly

feature/cython
informatic 2017-06-13 20:22:52 +02:00
parent 8f1d906e9c
commit 1e8031775c
2 changed files with 7 additions and 2 deletions

View File

@ -4,9 +4,10 @@
<div class="row">
<div class="col-md-4 col-md-offset-4 well">
<form action="{{ url_for('.login_submit') }}" class="loginform" method="POST">
{% if not logged_in %}
<input type="text" name="username" placeholder="username" class="form-control input-lg" autofocus />
<input type="password" name="password" placeholder="password" class="form-control input-lg" />
{% if next %}
<input type="hidden" name="next" value="{{ next }}" />
{% endif %}
<button class="btn btn-lg btn-block">Login</button>

View File

@ -74,12 +74,16 @@ def transfer():
@bp.route('/login')
def login():
return render_template('login.html')
return render_template('login.html', next=request.args.get('next'))
@bp.route('/login', methods=['POST'])
def login_submit():
if try_login(request.form.get('username'), request.form.get('password')):
flash('Login successful', 'success')
if request.form.get('next'):
return redirect(request.form.get('next'))
return redirect('/')
flash('Login failed', 'danger')