Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Recovering from a lost BTCPay password w/o SMTP set up

You setup a btcpay server account, forgot to setup SMTP (or set it up wrong) and then forgot your password. Now you can't get back in. Here's how I recovered from this situation:

  1. Create a new user according to these instructions. But this isn't enough because (1) Your new user isn't a member of any stores and (2) for me at least this new user couldn't setup SMTP ...

  2. There is a postgres table called UserStore which tracks membership of users in stores. When you execute the following command in postgres

select * from "UserStore";

You will get see all memberships

           ApplicationUserId           |                 StoreDataId                  | Role  
  old-user-id                          | store-1-id                                   | Owner
  old-user-id                          | store-2-id                                   | Owner
  old-user-id                          | ...                                          | Owner

If you execute select "Id", "Email" from "AspNetUsers" you will see that your new user isn't a member in any Store b/c their Id doesn't appear anywhere in the table above.

If you want to only add the new user to certain stores, or if you have more than 2 users and don't want everyone to be a member of every store, you can simply execute the following query for each pair of (AspNetUsers.Id, UserStore.StoreDataId) pair you want to create a store membership for:

insert into "UserStore"
values ('<some>', '<some UserStore.StoreDataId>');

Or you can execute this query to add all users to all stores:

insert into "UserStore" ("ApplicationUserId", "StoreDataId", "Role" ) 
select "Id", "StoreDataId", 'Owner' from 
  (select "Id" from "AspNetUsers" 
     left join "UserStore" on "Id" = "ApplicationUserId" 
     where "ApplicationUserId" is Null
  ) as users_without_stores
  natural join 
  (select "StoreDataId" from "UserStore") as store_ids;
  1. (Optional) Go into "Server Settings > Users" in BTCPay web UI and remove the old admin user.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.