auth providers

This commit is contained in:
Mateusz Gruszczyński
2026-05-25 08:38:08 +02:00
parent f79e072610
commit 352c53617c
8 changed files with 235 additions and 19 deletions

View File

@@ -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")