Quick fix for the signin page, we should consider moving it over to AJAX though.
This commit is contained in:
parent
e81a24a9ce
commit
4746f9c324
3 changed files with 21 additions and 8 deletions
|
@ -1,6 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from flask import abort, send_file, redirect, request, url_for
|
from flask import (abort, send_file, redirect, request, url_for,
|
||||||
|
render_template)
|
||||||
from flask.ext.login import login_user, UserMixin, login_required, logout_user
|
from flask.ext.login import login_user, UserMixin, login_required, logout_user
|
||||||
from flask.ext.principal import identity_changed, Identity, AnonymousIdentity
|
from flask.ext.principal import identity_changed, Identity, AnonymousIdentity
|
||||||
|
|
||||||
|
@ -42,6 +43,11 @@ def common_login(db_user):
|
||||||
identity_changed.send(app, identity=Identity(db_user.username, 'username'))
|
identity_changed.send(app, identity=Identity(db_user.username, 'username'))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/signin', methods=['GET'])
|
||||||
|
def render_signin_page():
|
||||||
|
return render_template('signin.html')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/signin', methods=['POST'])
|
@app.route('/signin', methods=['POST'])
|
||||||
def signin():
|
def signin():
|
||||||
username = request.form['username']
|
username = request.form['username']
|
||||||
|
@ -54,7 +60,10 @@ def signin():
|
||||||
|
|
||||||
return redirect(request.args.get('next') or url_for('index'))
|
return redirect(request.args.get('next') or url_for('index'))
|
||||||
|
|
||||||
abort(403)
|
else:
|
||||||
|
return render_template('signin.html',
|
||||||
|
username=username,
|
||||||
|
error='Invalid username or password.')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/confirm', methods=['GET'])
|
@app.route('/confirm', methods=['GET'])
|
||||||
|
@ -72,11 +81,6 @@ def password_reset():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@app.route('/signin', methods=['GET'])
|
|
||||||
def render_signin_page():
|
|
||||||
return send_file('templates/signin.html')
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/signout")
|
@app.route("/signout")
|
||||||
@login_required
|
@login_required
|
||||||
def logout():
|
def logout():
|
||||||
|
|
|
@ -37,4 +37,9 @@ body {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
border-top-left-radius: 0;
|
border-top-left-radius: 0;
|
||||||
border-top-right-radius: 0;
|
border-top-right-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert {
|
||||||
|
max-width: 300px;
|
||||||
|
margin: 0 auto;
|
||||||
}
|
}
|
|
@ -10,10 +10,14 @@
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<form method="post" class="form-signin">
|
<form method="post" class="form-signin">
|
||||||
<input type="text" class="form-control" placeholder="Username" name="username" autofocus>
|
<input type="text" class="form-control" placeholder="Username" name="username" value="{{ username }}"autofocus>
|
||||||
<input type="password" class="form-control" placeholder="Password" name="password">
|
<input type="password" class="form-control" placeholder="Password" name="password">
|
||||||
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign In</button>
|
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign In</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
{% if error %}
|
||||||
|
<div class="alert alert-danger">{{ error }}</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Reference in a new issue