Handle the confirmation codes to validate user emails.
This commit is contained in:
parent
5508402bb7
commit
32581c0621
4 changed files with 32 additions and 14 deletions
|
@ -36,6 +36,12 @@ def index():
|
|||
return send_file('templates/index.html')
|
||||
|
||||
|
||||
def common_login(db_user):
|
||||
logger.debug('Successfully signed in as: %s' % db_user.username)
|
||||
login_user(_LoginWrappedDBUser(db_user))
|
||||
identity_changed.send(app, identity=Identity(db_user.username, 'username'))
|
||||
|
||||
|
||||
@app.route('/signin', methods=['POST'])
|
||||
def signin():
|
||||
username = request.form['username']
|
||||
|
@ -44,12 +50,7 @@ def signin():
|
|||
#TODO Allow email login
|
||||
verified = model.verify_user(username, password)
|
||||
if verified:
|
||||
logger.debug('Successfully signed in as: %s' % username)
|
||||
|
||||
login_user(_LoginWrappedDBUser(verified))
|
||||
|
||||
identity_changed.send(app, identity=Identity(verified.username,
|
||||
'username'))
|
||||
common_login(verified)
|
||||
|
||||
return redirect(request.args.get('next') or url_for('index'))
|
||||
|
||||
|
@ -58,7 +59,12 @@ def signin():
|
|||
|
||||
@app.route('/confirm', methods=['GET'])
|
||||
def confirm_email():
|
||||
pass
|
||||
code = request.values['code']
|
||||
user = model.confirm_user_email(code)
|
||||
|
||||
common_login(user)
|
||||
|
||||
return redirect(url_for('index'))
|
||||
|
||||
|
||||
@app.route('/reset', methods=['GET'])
|
||||
|
|
Reference in a new issue