Skip to content

feat(web): manage admin users - #15380

Merged
alextran1502 merged 1 commit into
immich-app:mainfrom
nosajthenitram:feat/web_user_admin_switch
Jun 12, 2025
Merged

alextran1502 merged 1 commit into
immich-app:mainfrom
nosajthenitram:feat/web_user_admin_switch

Conversation

@nosajthenitram

@nosajthenitram nosajthenitram commented Jan 16, 2025 •

Copy link
Copy Markdown
Contributor

Add the option to configure the isAdmin flag on a user.

image

An admin user cannot edit this property on their own user.

@bo0tzz

bo0tzz commented Jan 16, 2025

Copy link
Copy Markdown
Member

I believe currently with this it would be possible for the last admin to remove their own admin permissions, right?

@danieldietzler

Copy link
Copy Markdown
Member

I believe currently with this it would be possible for the last admin to remove their own admin permissions, right?

Yup. And your diff of the generated files looks pretty broken, please fix that and your tests @nosajthenitram

@nosajthenitram

nosajthenitram commented Jan 16, 2025 •

Copy link
Copy Markdown
Contributor Author

I believe currently with this it would be possible for the last admin to remove their own admin permissions, right?

Yup. And your diff of the generated files looks pretty broken, please fix that and your tests @nosajthenitram

It shouldn't be possible for the last admin to remove admin rights for themselves, as there's a disable switch condition based on whether or not the current user is equal to the selected user. Would need to think through the race condition of two admins removing one another's rights at the same time.

Will clean up the generated file as well as look at some test augmentation.

@alextran1502

Copy link
Copy Markdown
Member

Would need to think through the race condition of two admins removing one another's rights at the same time.

You can probably put this in a queue and check for the database before making the changes in the database

@bo0tzz

bo0tzz commented Jan 16, 2025

Copy link
Copy Markdown
Member

A database lock could be appropriate, I think doing it through a queue is unnecessarily complex. What I think would be a better/more useful safety measure is to add an immich-admin subcommand to promote a user to admin.

@alextran1502

Copy link
Copy Markdown
Member

What I think would be a better/more useful safety measure is to add an immich-admin subcommand to promote a user to admin.

I like this idea, @nosajthenitram. Can we go with this instead?

@nosajthenitram

nosajthenitram commented Jan 16, 2025 •

Copy link
Copy Markdown
Contributor Author

A database lock could be appropriate, I think doing it through a queue is unnecessarily complex. What I think would be a better/more useful safety measure is to add an immich-admin subcommand to promote a user to admin.

The immich-admin commands utilizes the same underlying psql queries, which doesn't offer any additional atomic database access. Why is this the preferred method? Seems as though the same race condition would exist, just moving it from the web to the server?

@alextran1502 Can you elaborate on the immich-admin as the preferred method?

@bo0tzz

bo0tzz commented Jan 16, 2025

Copy link
Copy Markdown
Member

The idea is to not try all too hard to prevent the problem (disabling the toggle like you already do should make it exceedingly rare already), but make it really easy to fix instead with an admin command.

@nosajthenitram

Copy link
Copy Markdown
Contributor Author

The idea is to not try all too hard to prevent the problem (disabling the toggle like you already do should make it exceedingly rare already), but make it really easy to fix instead with an admin command.

Gotcha, in addition to the Web control a command to grant admin access to a user. Not necessarily the primary use case, but a CYA.

@nosajthenitram

Copy link
Copy Markdown
Contributor Author

The idea is to not try all too hard to prevent the problem (disabling the toggle like you already do should make it exceedingly rare already), but make it really easy to fix instead with an admin command.

Gotcha, in addition to the Web control a command to grant admin access to a user. Not necessarily the primary use case, but a CYA.

@danieldietzler prefer a single branch with the immich-admin command and web interface updates? Or multi-branch since someone else is responsible for server features?

@danieldietzler

Copy link
Copy Markdown
Member

@nosajthenitram if you're happy to do both, feel free to put it all in this PR. It shouldn't be too much in total.

@nosajthenitram

Copy link
Copy Markdown
Contributor Author

@nosajthenitram if you're happy to do both, feel free to put it all in this PR. It shouldn't be too much in total.

@danieldietzler I've added commands for grant and remove admin (figured why bother with a one way street, someone may find the remove command useful in automation), and it's a not a huge changeset

@bo0tzz

bo0tzz commented Jan 17, 2025

Copy link
Copy Markdown
Member

I think you may have forgotten to push your changes?

@nosajthenitram

Copy link
Copy Markdown
Contributor Author

I think you may have forgotten to push your changes?

No, I'm trying to figure out why server tests are failing (storage related, nothing I've changed) and adding some tests as recommended above. I'm completely new to this code base, so it's taking some time to understand how it's all thrown together.

@bo0tzz

bo0tzz commented Jan 17, 2025

Copy link
Copy Markdown
Member

All good, no rush!

Comment thread server/src/services/user-admin.service.ts Outdated
@nosajthenitram

Copy link
Copy Markdown
Contributor Author

ok, tests added and files cleaned up. let's see how this goes :D

@danieldietzler danieldietzler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good overall, just some minor nits :)

Comment thread e2e/src/web/specs/useradmin.e2e-spec.ts Outdated
Comment thread server/src/services/cli.service.ts Outdated
Comment thread i18n/en.json Outdated
@alextran1502
alextran1502 enabled auto-merge (squash) January 30, 2025 02:15
@jrasm91
jrasm91 force-pushed the feat/web_user_admin_switch branch from a556b4e to 7e26488 Compare June 12, 2025 01:02
@jrasm91 jrasm91 changed the title feat(web): Added admin user config to user settings feat(web): manage admin users Jun 12, 2025
@jrasm91
jrasm91 force-pushed the feat/web_user_admin_switch branch from 7e26488 to 4df0143 Compare June 12, 2025 01:59
@jrasm91
jrasm91 force-pushed the feat/web_user_admin_switch branch from 4df0143 to 8cde021 Compare June 12, 2025 02:04
@alextran1502
alextran1502 merged commit e5219f1 into immich-app:main Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants