From 0c66ced9154ace67366005357a691dc8e9888906 Mon Sep 17 00:00:00 2001 From: Ivo Oskamp Date: Tue, 13 Jan 2026 12:52:53 +0100 Subject: [PATCH] Auto-commit local changes before build (2026-01-13 12:52:53) --- .last-branch | 2 +- .../backupchecks/src/backend/app/auth/routes.py | 11 ++++++----- docs/changelog.md | 7 +++++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.last-branch b/.last-branch index 114cb12..ed45888 100644 --- a/.last-branch +++ b/.last-branch @@ -1 +1 @@ -v20260113-03-runchecks-overall-remark +v20260113-04-edge-initial-setup-users-exist diff --git a/containers/backupchecks/src/backend/app/auth/routes.py b/containers/backupchecks/src/backend/app/auth/routes.py index f0d7149..bb716ef 100644 --- a/containers/backupchecks/src/backend/app/auth/routes.py +++ b/containers/backupchecks/src/backend/app/auth/routes.py @@ -18,8 +18,9 @@ from ..models import User auth_bp = Blueprint("auth", __name__, url_prefix="/auth") -def admin_exists() -> bool: - return db.session.query(User.id).filter_by(role="admin").first() is not None +def users_exist() -> bool: + # Initial setup should only run on a fresh install where NO users exist yet. + return db.session.query(User.id).first() is not None def generate_captcha(): @@ -55,7 +56,7 @@ def captcha_required(func): @captcha_required def login(): if request.method == "GET": - if not admin_exists(): + if not users_exist(): return redirect(url_for("auth.initial_setup")) question, answer = generate_captcha() @@ -98,8 +99,8 @@ def logout(): @auth_bp.route("/initial-setup", methods=["GET", "POST"]) def initial_setup(): - if admin_exists(): - flash("An admin user already exists. Please log in.", "info") + if users_exist(): + flash("Users already exist. Please log in.", "info") return redirect(url_for("auth.login")) if request.method == "POST": diff --git a/docs/changelog.md b/docs/changelog.md index 0efbf1f..9556805 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -20,6 +20,13 @@ - Added support to display the overall remark (overall_message) on the Run Checks page. - Ensured consistency between the Run Checks view and the Job Details page where the overall remark was already available. +--- + +## v20260113-04-edge-initial-setup-users-exist +- Fixed incorrect redirect to the “Initial admin setup” page when users already exist. +- Changed the setup check from “admin user exists” to “any user exists”, so existing environments always show the login page instead of allowing a new initial admin to be created. +- Prevented direct access to the initial setup route when at least one user is present (redirects to login). + *** ## v0.1.20