30 lines
No EOL
712 B
Python
30 lines
No EOL
712 B
Python
from flask import abort, send_file, redirect, request
|
|
|
|
from data import model
|
|
from app import app
|
|
|
|
|
|
@app.route('/', methods=['GET'])
|
|
def index():
|
|
return send_file('templates/index.html')
|
|
|
|
|
|
@app.route('/signin', methods=['POST'])
|
|
def signin():
|
|
username = request.form['username']
|
|
password = request.form['password']
|
|
|
|
#TODO Allow email login
|
|
verified = model.verify_user(username, password)
|
|
if verified:
|
|
logger.debug('Successfully signed in as: %s' % username)
|
|
|
|
login_user(_LoginWrappedDBUser(verified))
|
|
return redirect(request.args.get('next') or url_for('index'))
|
|
|
|
abort(403)
|
|
|
|
|
|
@app.route('/signin', methods=['GET'])
|
|
def render_signin_page():
|
|
return send_file('templates/signin.html') |