[Bug]: Recover the account before the delete script starts #448

Closed
opened 2026-02-04 20:31:22 +03:00 by OVERLORD · 19 comments
Owner

Originally created by @NeleB54Gold on GitHub (Nov 26, 2022).

Feature detail

i'm so stupid i requested deletion of the only admin account on immich, how can i cancel it?
I stopped the docker before it can start delete everything, please HELP

Platform

Server

Originally created by @NeleB54Gold on GitHub (Nov 26, 2022). ### Feature detail i'm so stupid i requested deletion of the only admin account on immich, how can i cancel it? I stopped the docker before it can start delete everything, please HELP ### Platform Server
Author
Owner

@jrasm91 commented on GitHub (Nov 26, 2022):

If you have access to the database you can null out the deleted at column for the user to undo it.

Or, I wonder if you can create a second admin account and then use that to undo the first one.

@jrasm91 commented on GitHub (Nov 26, 2022): If you have access to the database you can null out the deleted at column for the user to undo it. Or, I wonder if you can create a second admin account and then use that to undo the first one.
Author
Owner

@NeleB54Gold commented on GitHub (Nov 26, 2022):

If you have access to the database you can null out the deleted at column for the user to undo it.

Or, I wonder if you can create a second admin account and then use that to undo the first one.

How can I read the postgre database in order to change it/add a new account?

@NeleB54Gold commented on GitHub (Nov 26, 2022): > If you have access to the database you can null out the deleted at column for the user to undo it. > > Or, I wonder if you can create a second admin account and then use that to undo the first one. How can I read the postgre database in order to change it/add a new account?
Author
Owner

@alextran1502 commented on GitHub (Nov 26, 2022):

Assuming your database name is immich and your database user is postgres (default value from Immich)

  1. Attach to the Postgres container
  2. execute psql -U postgres -d immich
  3. Then execute
UPDATE users
SET "deletedAt" = null
WHERE email = 'your-admin-email';

Should be good to go.

@alextran1502 commented on GitHub (Nov 26, 2022): Assuming your database name is `immich` and your database user is `postgres` (default value from Immich) 1. Attach to the Postgres container 2. execute `psql -U postgres -d immich` 3. Then execute ```sql UPDATE users SET "deletedAt" = null WHERE email = 'your-admin-email'; ``` Should be good to go.
Author
Owner

@jrasm91 commented on GitHub (Nov 26, 2022):

Maybe it would be good to add some checks that prevent deleting the admin account 😛.

It also might be worthwhile to add some cli commands to help with resolving some of these database related fixes, like make a user an admin, etc.

@jrasm91 commented on GitHub (Nov 26, 2022): Maybe it would be good to add some checks that prevent deleting the admin account 😛. It also might be worthwhile to add some cli commands to help with resolving some of these database related fixes, like make a user an admin, etc.
Author
Owner

@alextran1502 commented on GitHub (Nov 26, 2022):

Maybe it would be good to add some checks that prevent deleting the admin account 😛.

It also might be worthwhile to add some cli commands to help with resolving some of these database related fixes, like make a user an admin, etc.

From the PR deleting user I remember I saw that check 🤔

@alextran1502 commented on GitHub (Nov 26, 2022): > Maybe it would be good to add some checks that prevent deleting the admin account 😛. > > It also might be worthwhile to add some cli commands to help with resolving some of these database related fixes, like make a user an admin, etc. From the PR deleting user I remember I saw that check 🤔
Author
Owner

@alextran1502 commented on GitHub (Nov 26, 2022):

Maybe it would be good to add some checks that prevent deleting the admin account 😛.
It also might be worthwhile to add some cli commands to help with resolving some of these database related fixes, like make a user an admin, etc.

From the PR deleting user I remember I saw that check 🤔

damnit I missed it

@alextran1502 commented on GitHub (Nov 26, 2022): > > Maybe it would be good to add some checks that prevent deleting the admin account 😛. > > It also might be worthwhile to add some cli commands to help with resolving some of these database related fixes, like make a user an admin, etc. > > From the PR deleting user I remember I saw that check 🤔 damnit I missed it
Author
Owner

@NeleB54Gold commented on GitHub (Nov 27, 2022):

Assuming your database name is immich and your database user is postgres (default value from Immich)

  1. Attach to the Postgres container
  2. execute psql -U postgres -d immich
  3. Then execute
UPDATE users
SET "deletedAt" = null
WHERE email = 'your-admin-email';

Should be good to go.

I'm sorry, I'm not an expert with docker, how can I find the immich name to attach?
I tried with immich, immich-app, immich_app, but maybe is an ID from the conteiner idk

@NeleB54Gold commented on GitHub (Nov 27, 2022): > Assuming your database name is `immich` and your database user is `postgres` (default value from Immich) > > 1. Attach to the Postgres container > 2. execute `psql -U postgres -d immich` > 3. Then execute > > ```sql > UPDATE users > SET "deletedAt" = null > WHERE email = 'your-admin-email'; > ``` > > Should be good to go. I'm sorry, I'm not an expert with docker, how can I find the immich name to attach? I tried with immich, immich-app, immich_app, but maybe is an ID from the conteiner idk
Author
Owner

@jrasm91 commented on GitHub (Nov 27, 2022):

You can run docker ps to get a list of running containers, or docker ps -a to include ones that are stopped.

Also, it'd probably be easier to assist/chat/help if you posted on discord, instead of using this GitHub issue.

@jrasm91 commented on GitHub (Nov 27, 2022): You can run docker ps to get a list of running containers, or docker ps -a to include ones that are stopped. Also, it'd probably be easier to assist/chat/help if you posted on discord, instead of using this GitHub issue.
Author
Owner

@alextran1502 commented on GitHub (Nov 27, 2022):

With docker ps you will see a list below
Screenshot 2022-11-26 at 15 10 26

Then using the command below to get into the container

docker exec -it immich_postgres bash
@alextran1502 commented on GitHub (Nov 27, 2022): With `docker ps` you will see a list below <img width="1633" alt="Screenshot 2022-11-26 at 15 10 26" src="https://user-images.githubusercontent.com/27055614/204109067-ff025583-3926-4867-a990-4cf3516fc64c.png"> Then using the command below to get into the container ``` docker exec -it immich_postgres bash ```
Author
Owner

@NeleB54Gold commented on GitHub (Nov 27, 2022):

Cattura

Ok, I recovered my account, but why the other account is still there?
I deleted the "salvatore"'s account, and when I clicked on it too many time (yes, I know, sometimes I'm really stupid), probably some ID changed in order to delete my account, because, how can I delete myself from my profile?

@NeleB54Gold commented on GitHub (Nov 27, 2022): ![Cattura](https://user-images.githubusercontent.com/51356760/204109446-a8e3bdc1-65b3-4293-abcb-668f06bc64a1.PNG) Ok, I recovered my account, but why the other account is still there? I deleted the "salvatore"'s account, and when I clicked on it too many time (yes, I know, sometimes I'm really stupid), probably some ID changed in order to delete my account, because, how can I delete myself from my profile?
Author
Owner

@alextran1502 commented on GitHub (Nov 27, 2022):

Cattura

Ok, I recovered my account, but why the other account is still there? I deleted the "salvatore"'s account, and when I clicked on it too many time (yes, I know, sometimes I'm really stupid), probably some ID changed in order to delete my account, because, how can I delete myself from my profile?

So the salvator account is a non-admin account, correct?

@alextran1502 commented on GitHub (Nov 27, 2022): > ![Cattura](https://user-images.githubusercontent.com/51356760/204109446-a8e3bdc1-65b3-4293-abcb-668f06bc64a1.PNG) > > Ok, I recovered my account, but why the other account is still there? I deleted the "salvatore"'s account, and when I clicked on it too many time (yes, I know, sometimes I'm really stupid), probably some ID changed in order to delete my account, because, how can I delete myself from my profile? So the `salvator` account is a non-admin account, correct?
Author
Owner

@NeleB54Gold commented on GitHub (Nov 27, 2022):

Cattura
Ok, I recovered my account, but why the other account is still there? I deleted the "salvatore"'s account, and when I clicked on it too many time (yes, I know, sometimes I'm really stupid), probably some ID changed in order to delete my account, because, how can I delete myself from my profile?

So the salvator account is a non-admin account, correct?

Correct, now the schedule delete go to 3 December, it's 7 days later, maybe I need to update immich to be sure that it can be deleted that day, but it's ok, the salvatore have no media files on it, it was only an account management test for me

@NeleB54Gold commented on GitHub (Nov 27, 2022): > > ![Cattura](https://user-images.githubusercontent.com/51356760/204109446-a8e3bdc1-65b3-4293-abcb-668f06bc64a1.PNG) > > Ok, I recovered my account, but why the other account is still there? I deleted the "salvatore"'s account, and when I clicked on it too many time (yes, I know, sometimes I'm really stupid), probably some ID changed in order to delete my account, because, how can I delete myself from my profile? > > So the `salvator` account is a non-admin account, correct? Correct, now the schedule delete go to 3 December, it's 7 days later, maybe I need to update immich to be sure that it can be deleted that day, but it's ok, the salvatore have no media files on it, it was only an account management test for me
Author
Owner

@alextran1502 commented on GitHub (Nov 27, 2022):

The delete action will trigger 7 days grace period where you can recover the account.

I wonder how did you delete the admin account in the first place. Or do you mean you were deleting the non-admin account salvatore? Note that the admin account doesn't show up in the user management.

@alextran1502 commented on GitHub (Nov 27, 2022): The delete action will trigger 7 days grace period where you can recover the account. I wonder how did you delete the admin account in the first place. Or do you mean you were deleting the non-admin account `salvatore`? Note that the admin account doesn't show up in the user management.
Author
Owner

@NeleB54Gold commented on GitHub (Nov 27, 2022):

The delete action will trigger 7 days grace period where you can recover the account.

I wonder how did you delete the admin account in the first place. Or do you mean you were deleting the non-admin account salvatore? Note that the admin account doesn't show up in the user management.

As I said before, I was constantly clicking on the button to delete Salvatore's account, and I don't know how, and I scheduled the deletion to mine, because it wouldn't let me login anymore and when i updated with the request on the database i was able to login again. Oof, really, I want to help, but this time was totally random

@NeleB54Gold commented on GitHub (Nov 27, 2022): > The delete action will trigger 7 days grace period where you can recover the account. > > I wonder how did you delete the admin account in the first place. Or do you mean you were deleting the non-admin account `salvatore`? Note that the admin account doesn't show up in the user management. As I said before, I was constantly clicking on the button to delete Salvatore's account, and I don't know how, and I scheduled the deletion to mine, because it wouldn't let me login anymore and when i updated with the request on the database i was able to login again. Oof, really, I want to help, but this time was totally random
Author
Owner

@alextran1502 commented on GitHub (Nov 27, 2022):

Hmm strange, but good report, though. I will take a look at the continuation clicking on the button. I guess we can close this issue.

@alextran1502 commented on GitHub (Nov 27, 2022): Hmm strange, but good report, though. I will take a look at the continuation clicking on the button. I guess we can close this issue.
Author
Owner

@NeleB54Gold commented on GitHub (Nov 27, 2022):

Hmm strange, but good report, though. I will take a look at the continuation clicking on the button. I guess we can close this issue.

Yes, thank you all for the instant help!

@NeleB54Gold commented on GitHub (Nov 27, 2022): > Hmm strange, but good report, though. I will take a look at the continuation clicking on the button. I guess we can close this issue. Yes, thank you all for the instant help!
Author
Owner

@jrasm91 commented on GitHub (Nov 27, 2022):

I think there is a bug where email is not uniquely enforced at the database level so two request (submit button clicked twice quickly) can cause two accounts with the same email to be successfully created. I know we patched the UI for this, but maybe there are two accounts with the same email and that has led to this weird situation/behavior.

Can you use SQL to list all the users? I bet there are two with the same email, one or both are admins.

@jrasm91 commented on GitHub (Nov 27, 2022): I think there is a bug where email is not uniquely enforced at the database level so two request (submit button clicked twice quickly) can cause two accounts with the same email to be successfully created. I know we patched the UI for this, but maybe there are two accounts with the same email and that has led to this weird situation/behavior. Can you use SQL to list all the users? I bet there are two with the same email, one or both are admins.
Author
Owner

@NeleB54Gold commented on GitHub (Nov 27, 2022):

I think there is a bug where email is not uniquely enforced at the database level so two request (submit button clicked twice quickly) can cause two accounts with the same email to be successfully created. I know we patched the UI for this, but maybe there are two accounts with the same email and that has led to this weird situation/behavior.

Can you use SQL to list all the users? I bet there are two with the same email, one or both are admins.

Oh, ok, I'm on my phone now, sorry for Termius quality lol
20221126_230935.jpg

@NeleB54Gold commented on GitHub (Nov 27, 2022): > I think there is a bug where email is not uniquely enforced at the database level so two request (submit button clicked twice quickly) can cause two accounts with the same email to be successfully created. I know we patched the UI for this, but maybe there are two accounts with the same email and that has led to this weird situation/behavior. > > Can you use SQL to list all the users? I bet there are two with the same email, one or both are admins. Oh, ok, I'm on my phone now, sorry for Termius quality lol ![20221126_230935.jpg](https://user-images.githubusercontent.com/51356760/204110769-8fc5fdff-b320-417c-af11-589835902b6c.jpg)
Author
Owner

@jrasm91 commented on GitHub (Nov 27, 2022):

Looks normal/good, so there goes that theory!

@jrasm91 commented on GitHub (Nov 27, 2022): Looks normal/good, so there goes that theory!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#448