Skip to content

Add script to change Super Admin#416

Merged
fccview merged 2 commits intofccview:developfrom
bothored:change-super-admin
Feb 16, 2026
Merged

Add script to change Super Admin#416
fccview merged 2 commits intofccview:developfrom
bothored:change-super-admin

Conversation

@bothored
Copy link
Copy Markdown
Contributor

@bothored bothored commented Feb 15, 2026

This adds a script to give a new user Super Admin privileges.

This is most likely going to occur if someone starts with built-in authentication and moves to SSO, and their new username doesn't match. Therefore the howto/SSO.md references the script. Happy to add to any other parts of the docs if it makes sense.

The script will:

  • Take the new username and path to the users.json
  • Validate the user exists and it can find the current super admin
  • Demote the current super admin (leaving it as Admin still)
  • Promote the new super admin (setting both isSuperAdmin and isAdmin in case it wasn't already admin)
  • The original users.json is backed up to users.json.bak in case they want to revert

As it is a bash script and therefore has no unit tests, here are the tests:

# original users.json
[
  {
    "username": "joe",
    "passwordHash": "<snip>",
    "isAdmin": true,
    "isSuperAdmin": true,
    "failedLoginAttempts": 0,
    "lastLogin": "2026-02-15T09:30:31.816Z"
  },
  {
    "username": "fred",
    "passwordHash": "<snip>",
    "isAdmin": true,
    "createdAt": "2026-02-13T09:18:08.887Z",
    "lastLogin": "2026-02-13T09:18:17.629Z",
    "preferredDateFormat": "dd/mm/yyyy",
    "preferredTimeFormat": "12-hours",
    "handedness": "right-handed",
    "failedLoginAttempts": 0,
    "isSuperAdmin": false
  }
]

bash scripts/update-super-admin.sh fred data/users/users.json
Current super admin is: joe
Demoting...
Promoting new super admin: fred
Backing up existing users.json to: data/users/users.json.bak
Updating data/users/users.json.
Done. Remove data/users/users.json.bak after verifying result.

# New users.json
[
  {
    "username": "joe",
    "passwordHash": "<snip>",
    "isAdmin": true,
    "isSuperAdmin": false,
    "failedLoginAttempts": 0,
    "lastLogin": "2026-02-15T09:30:31.816Z"
  },
  {
    "username": "fred",
    "passwordHash": "<snip>",
    "isAdmin": true,
    "createdAt": "2026-02-13T09:18:08.887Z",
    "lastLogin": "2026-02-13T09:18:17.629Z",
    "preferredDateFormat": "dd/mm/yyyy",
    "preferredTimeFormat": "12-hours",
    "handedness": "right-handed",
    "failedLoginAttempts": 0,
    "isSuperAdmin": true
  }
]

# Malformed JSON text (removed a random `}`)
bash scripts/update-super-admin.sh fred data/users/users.json
jq: parse error: Unmatched ']' at line 22, column 1
The user fred does not exist.

# No current Super Admin
[
  {
    "username": "joe",
    "passwordHash": "<snip>",
    "isAdmin": true,
    "isSuperAdmin": false,
    "failedLoginAttempts": 0,
    "lastLogin": "2026-02-15T09:30:31.816Z"
  },
  {
    "username": "fred",
    "passwordHash": "<snip>",
    "isAdmin": true,
    "createdAt": "2026-02-13T09:18:08.887Z",
    "lastLogin": "2026-02-13T09:18:17.629Z",
    "preferredDateFormat": "dd/mm/yyyy",
    "preferredTimeFormat": "12-hours",
    "handedness": "right-handed",
    "failedLoginAttempts": 0,
    "isSuperAdmin": false
  }
]

bash scripts/update-super-admin.sh fred data/users/users.json
No existing super admin found. Aborting.

To be explicit on the topic as I'm a new contributor - all code written is written by me directly.

The script is runnable from the server host and portable.
It can be downloaded from GitHub and used.
@fccview
Copy link
Copy Markdown
Owner

fccview commented Feb 15, 2026

This is fantastic!
Gonna test it out as soon as I have a minute and get it merged, thank you for this great contribution!

@fccview fccview merged commit 1454778 into fccview:develop Feb 16, 2026
2 checks passed
@fccview
Copy link
Copy Markdown
Owner

fccview commented Feb 16, 2026

merged, stellar work! ❤️

@bothored
Copy link
Copy Markdown
Contributor Author

merged, stellar work! ❤️

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants