Admin Area
The admin area are the back office where you should build the features that you don’t want the customers to see. Out of the box, you can see the accounts, users and also the products and product subscriptions.
Create the initial admin
To be able to access the admin area, you need to create an admin user for yourself. You can do that in two ways.
Create an admin in the sign in form
Make sure that the server is running and visit http://localhost:4000/admin
You should be redirected to a page where you can create the first admin. Put in your email and press enter. You should be signed in and get an autogenerated password for you.
Create an admin in the iex console
Enter the console by typing in the terminal
iex -S mix
Call the generate admin function and pass in the email address
MyApp.Admins.GenerateAdmin.generate_admin("john.doe@example.com")
=> {:ok, "john.doe@example.com", "xYCCRX8zxY-v"}
This should return an ok-tuple with the email and autogenerated password.
Login with magic link
There is no admin forgotten password functionality. However, there is a login with magic link-functionality. Basically, just go to http://localhost:4000/admin/reset_password and type in your email and if it exists in the admin-table an email will be delivered. In development, you can see the sent email by going to http://localhost:4000/dev/mailbox
Clicking the link in the email (or paste it in the browser) allows the admin to login.
Account scoped pages
Some pages like the admin users page, are account scoped. That means that you need to select an account from the list of accounts up in the menu. The reason is that account scoped pages by design should be kept separate to avoid mistakes and data leakage.
Impersonation
The SAAS Starter Kit comes with a way to impersonate a user and go to the app and perform the action as the impersonated user. Visit http://localhost:4000/admin/users and select a user on the list. If the user is not in the list, select the correct account on the account selector in the top menu.