Quick fix for the signin page, we should consider moving it over to AJAX though.

This commit is contained in:
yackob03 2013-10-01 13:48:37 -04:00
parent e81a24a9ce
commit 4746f9c324
3 changed files with 21 additions and 8 deletions

View file

@ -1,6 +1,7 @@
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.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'))
@app.route('/signin', methods=['GET'])
def render_signin_page():
return render_template('signin.html')
@app.route('/signin', methods=['POST'])
def signin():
username = request.form['username']
@ -54,7 +60,10 @@ def signin():
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'])
@ -72,11 +81,6 @@ def password_reset():
pass
@app.route('/signin', methods=['GET'])
def render_signin_page():
return send_file('templates/signin.html')
@app.route("/signout")
@login_required
def logout():

View file

@ -37,4 +37,9 @@ body {
margin-bottom: 10px;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
.alert {
max-width: 300px;
margin: 0 auto;
}

View file

@ -10,10 +10,14 @@
<body>
<div class="container">
<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">
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign In</button>
</form>
{% if error %}
<div class="alert alert-danger">{{ error }}</div>
{% endif %}
</div>
</body>
</html>