Files
notifications-admin/app/main/views/two_factor.py
Rebecca Law 9ba229820a 109638656: Implementation of two factor verification
Validation of the code is done in the form, when the form.validate_on_submit is called the validate code methods are called as well.
2015-12-09 11:36:57 +00:00

24 lines
648 B
Python

from flask import render_template, redirect, jsonify, session
from flask_login import login_user
from app.main import main
from app.main.dao import users_dao
from app.main.forms import TwoFactorForm
@main.route("/two-factor", methods=['GET'])
def render_two_factor():
return render_template('two-factor.html', form=TwoFactorForm())
@main.route('/two-factor', methods=['POST'])
def process_two_factor():
form = TwoFactorForm()
if form.validate_on_submit():
user = users_dao.get_user_by_id(session['user_id'])
login_user(user)
return redirect('/dashboard')
else:
return jsonify(form.errors), 400