Hello,
I have the following login code where, apart from verifying the username/password, I also later verify a token. Now what I would like would be that after verifying the password, redirect to another page (template to enter token) and write the token there, later if it is correct then redirect to home.
it’s possible?
def login():
if request.method=='POST':
user = request.form['username']
key = "****"
totp = pyotp.TOTP(key)
user = User(0,request.form['username'],request.form['password'])
logged_user=ModelUser.login(db,user)
if logged_user != None:
if logged_user.password:
login_user(logged_user)
code = request.form['code']
if totp.verify(code) == True:
return redirect(url_for('home'))
else:
flash("Token inválido")
return render_template('auth/login.html')
else:
flash("Contraseña inválida")
return render_template('auth/login.html')
else:
flash("Usuario no encontrado")
return render_template('auth/login.html')
else:
return render_template('auth/login.html')
Thank you