From 63315d388f2092ef4953778ad5c832aa11a67ca2 Mon Sep 17 00:00:00 2001 From: SysAdmin Agent Date: Sat, 9 May 2026 14:01:06 +0000 Subject: [PATCH] Improve GrampsWeb admin script: reset password if user exists (STI-90) When the admin user already exists with an unknown password, the startup script now attempts to reset the password instead of skipping. This handles the case where GrampsWeb was previously set up without tracking the admin credentials. Co-Authored-By: Paperclip --- compose.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/compose.yml b/compose.yml index f9340e5..26414a0 100644 --- a/compose.yml +++ b/compose.yml @@ -225,7 +225,7 @@ services: python3 << 'PYEOF' 2>&1 | grep -v Gtk from gramps_webapi.app import create_app from gramps_webapi.auth import add_user, get_number_users, ROLE_OWNER - import os + import os, sqlite3, hashlib email = os.environ.get('GRAMPSWEB_ADMIN_EMAIL', '') pw = os.environ.get('GRAMPSWEB_ADMIN_PASSWORD', '') if email and pw: @@ -235,7 +235,17 @@ services: add_user(name='Admin', email=email, password=pw, role=ROLE_OWNER) print('[grampsweb] Admin user created') else: - print('[grampsweb] Users already exist, skipping') + try: + add_user(name='Admin', email=email, password=pw, role=ROLE_OWNER) + print('[grampsweb] Admin user created') + except Exception: + from gramps_webapi.auth import get_user_details, modify_user + try: + user = get_user_details(name='Admin') + modify_user(name='Admin', password=pw, role=ROLE_OWNER) + print('[grampsweb] Admin user password reset') + except Exception as e: + print(f'[grampsweb] Could not update admin user: {e}') else: print('[grampsweb] No admin credentials configured, skipping') PYEOF