Skip to content

Instantly share code, notes, and snippets.

@lorenzobn
Last active September 19, 2021 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lorenzobn/e748b510c1858d0683738579bb74e8f9 to your computer and use it in GitHub Desktop.
Save lorenzobn/e748b510c1858d0683738579bb74e8f9 to your computer and use it in GitHub Desktop.
Snippet of code containing the login route for 2FA
@app.route("/login", methods=['GET', 'POST'])
def login():
form_user = request.form.get("username")
form_pass = request.form.get("password")
if request.method == 'POST':
if form_user == app.config["USER"] and form_pass == app.config["PASS"]:
session['username'] = form_user
return redirect(url_for("OTP_auth"))
else:
flash("Invalid credentials. Please try again.")
return redirect(url_for("index"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment