Create Flask Admin User
This will be a user with full admin rights to view the backend of your database. So this user should probably only be you as a solo founder / creator!
For reference you can see a full list of Flask Admin commands by running this:
flask users --help
This will generate the following output:
Usage: flask users [OPTIONS] **COMMAND** [ARGS]...
User commands.
For commands that require a USER - pass in any identity attribute.
Options:
--help Show this message and exit.
Commands:
activate Activate a user.
change_password Administratively change a user's password.
create Create a user.
deactivate Deactivate a user.
reset_access Reset all authentication credentials for user.
1. Create a new user:
flask users create [your-email-here]
Then you will be asked to create a new password, with this prompt:
Password:
After that you will be asked to confirm:
Repeat for confirmation:
If all worked correctly, you will see this message:
User created successfully.
{'email': '[your-email-here]', 'password': '****', 'active': False}
2. Activate the user:
flask users activate [your-email-here]
The terminal should then respond with this output:
User "[your-email-here]" has been activated.
3. Create an admin role. And add this role to the user you have just created:
flask roles create admin
flask roles add [your-email-here] admin
The terminal should then respond with this output:
Role "admin" added to user "[your-email-here]" successfully.
You will now use these admin credentials to log into your admin dashboard at localhost:5001/admin. (Only users with the role "admin" can do this as specified in app/admin_views.py). If you would like to learn more about this see my tutorial on securing your web app with Flask security here.
Now when you go to localhost:5001/admin and click on User on the navbar you will see your admin user entry: