Docker instance with no admins: How to add a user to the administrator group, from the cli? #7989
-
|
I look after an instance that has found itself in the incredible situation of having no users in the Administrator group, as the last remaining account with such privileges accidentally removed themselves from that group. And so it follows we have a large wiki with many users, none of whom can configure and admin the instance. Is there a way to promote an existing account to admin, from the cli ( I could poke around the Postgres db but fear breaking something I need not were there a known best practice solution to this problem. Any expert input greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
There is no need to guess the permission payload if the goal is only to put an existing user back into the built-in Administrators group. In the v2 schema the relation table is Safest recovery route:
SELECT id, email, name FROM users WHERE email = 'person@example.com';
SELECT id, name, permissions FROM groups WHERE name = 'Administrators';
INSERT INTO "userGroups" ("userId", "groupId")
SELECT u.id, g.id
FROM users u, groups g
WHERE u.email = 'person@example.com'
AND g.name = 'Administrators'
AND NOT EXISTS (
SELECT 1
FROM "userGroups" ug
WHERE ug."userId" = u.id
AND ug."groupId" = g.id
);Then restart the container and log in as that user. On the default v2 bootstrap the admin group is normally id 1, but selecting by group name is less brittle than hard-coding it. |
Beta Was this translation helpful? Give feedback.
-
|
Worked like a charm. Thanks a lot! Others in this rare predicament can confidently employ this solution. |
Beta Was this translation helpful? Give feedback.
There is no need to guess the permission payload if the goal is only to put an existing user back into the built-in Administrators group. In the v2 schema the relation table is
userGroups, users are inusers, and groups are ingroups. The setup code creates the system group namedAdministratorswithmanage:system, and assigns the initial admin by relating the user to that group.Safest recovery route: