#NEWLINE# @ auth . route ( '/verify' , methods = [ 'GET' , 'POST' ] ) #NEWLINE# @ login_required #NEWLINE# def verify( ) : #NEWLINE# #INDENT# 'Powers token validation (not using OneTouch)' #NEWLINE# form = VerifyForm ( request . form ) #NEWLINE# user = User . query . get ( session [ 'user_id' ] ) #NEWLINE# if ( request . method == 'GET' ) : #NEWLINE# #INDENT# send_authy_token_request ( user . authy_id ) #NEWLINE# #UNINDENT# if form . validate_on_submit ( ) : #NEWLINE# #INDENT# user_entered_code = form . verification_code . data #NEWLINE# verified = verify_authy_token ( user . authy_id , str ( user_entered_code ) ) #NEWLINE# if verified . ok ( ) : #NEWLINE# #INDENT# user . authy_status = 'approved' #NEWLINE# db . session . add ( user ) #NEWLINE# db . session . commit ( ) #NEWLINE# flash ( "You're logged in! Thanks for using two factor verification." , 'success' ) #NEWLINE# return redirect ( url_for ( 'main.account' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# form . errors [ 'verification_code' ] = [ 'Code invalid - please try again.' ] #NEWLINE# #UNINDENT# #UNINDENT# return render_template ( 'verify.html' , form = form )