fix: disable public signup and restore local login flow

This commit is contained in:
2026-04-13 10:06:56 +02:00
parent c4775c623f
commit 9a87ef9562
8 changed files with 70 additions and 17 deletions

View File

@@ -11,6 +11,10 @@ from ..models import User
bp = Blueprint("auth", __name__)
def registration_open() -> bool:
return User.query.count() == 0
@bp.route("/login", methods=["GET", "POST"])
def login():
if current_user.is_authenticated:
@@ -24,13 +28,16 @@ def login():
flash(f"Willkommen zurück, {user.name}.", "success")
return redirect(url_for("tasks.my_tasks"))
flash("Die Kombination aus E-Mail und Passwort passt leider nicht.", "error")
return render_template("auth/login.html", form=form)
return render_template("auth/login.html", form=form, registration_open=registration_open())
@bp.route("/register", methods=["GET", "POST"])
def register():
if current_user.is_authenticated:
return redirect(url_for("tasks.my_tasks"))
if not registration_open():
flash("Freie Registrierung ist deaktiviert.", "info")
return redirect(url_for("auth.login"))
form = RegisterForm()
if form.validate_on_submit():
@@ -50,4 +57,3 @@ def logout():
logout_user()
flash("Du bist jetzt abgemeldet.", "info")
return redirect(url_for("auth.login"))