auth providers
This commit is contained in:
@@ -174,13 +174,23 @@ def login():
|
||||
# Note: When optional authentication is disabled, /login is intentionally unavailable.
|
||||
if not auth.enabled():
|
||||
abort(404)
|
||||
next_url = request.args.get("next") or url_for("main.index")
|
||||
if auth.uses_external_provider():
|
||||
user = auth.authenticate_external_user()
|
||||
if user:
|
||||
return redirect(next_url)
|
||||
return render_template(
|
||||
"login.html",
|
||||
error="External authentication headers were not accepted by pyTorrent.",
|
||||
external_provider=auth.provider(),
|
||||
), 401
|
||||
error = ""
|
||||
if request.method == "POST":
|
||||
user = auth.login_user(request.form.get("username", ""), request.form.get("password", ""))
|
||||
if user:
|
||||
return redirect(request.args.get("next") or url_for("main.index"))
|
||||
return redirect(next_url)
|
||||
error = "Invalid username or password"
|
||||
return render_template("login.html", error=error)
|
||||
return render_template("login.html", error=error, external_provider=None)
|
||||
|
||||
|
||||
@bp.get("/logout")
|
||||
|
||||
Reference in New Issue
Block a user