Auto-commit local changes before build (2026-01-13 12:52:53) #109

Merged
ivooskamp merged 1 commits from v20260113-04-edge-initial-setup-users-exist into main 2026-01-13 13:20:07 +01:00
3 changed files with 14 additions and 6 deletions

View File

@ -1 +1 @@
v20260113-03-runchecks-overall-remark v20260113-04-edge-initial-setup-users-exist

View File

@ -18,8 +18,9 @@ from ..models import User
auth_bp = Blueprint("auth", __name__, url_prefix="/auth") auth_bp = Blueprint("auth", __name__, url_prefix="/auth")
def admin_exists() -> bool: def users_exist() -> bool:
return db.session.query(User.id).filter_by(role="admin").first() is not None # 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(): def generate_captcha():
@ -55,7 +56,7 @@ def captcha_required(func):
@captcha_required @captcha_required
def login(): def login():
if request.method == "GET": if request.method == "GET":
if not admin_exists(): if not users_exist():
return redirect(url_for("auth.initial_setup")) return redirect(url_for("auth.initial_setup"))
question, answer = generate_captcha() question, answer = generate_captcha()
@ -98,8 +99,8 @@ def logout():
@auth_bp.route("/initial-setup", methods=["GET", "POST"]) @auth_bp.route("/initial-setup", methods=["GET", "POST"])
def initial_setup(): def initial_setup():
if admin_exists(): if users_exist():
flash("An admin user already exists. Please log in.", "info") flash("Users already exist. Please log in.", "info")
return redirect(url_for("auth.login")) return redirect(url_for("auth.login"))
if request.method == "POST": if request.method == "POST":

View File

@ -20,6 +20,13 @@
- Added support to display the overall remark (overall_message) on the Run Checks page. - 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. - 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 ## v0.1.20