Strapi Plugin - Bootstrap admin user

Hello,

I’ve created a strapi plugin, which automatically creates the admin user on the development environment.

The first step verifies if the strapi-super-admin role exists; if it doesn’t exist, it creates one. The second step verifies if the admin user exists; if it doesn’t exist, it creates one with the strapi-super-admin role.

Installation

Yarn

yarn add strapi-plugin-bootstrap-admin-user

npm

npm install strapi-plugin-bootstrap-admin-user

Usage

Credentials will be outputed in console on the First run in the development environment.
image

Default credentials

Username: admin  
Password: admin  
Firstname: Admin  
Lastname: Admin  
Email: admin@strapi.dev

You can also define default credentials in .env with the following variables:

DEV_ADMIN_USERNAME  
DEV_ADMIN_PASSWORD
DEV_ADMIN_FIRSTNAME
DEV_ADMIN_LASTNAME
DEV_ADMIN_EMAIL

Note: Please use it only in the development environment.

Feel free to check it out on npm. Also, feel free to contribute to it on GitHub.

Thanks.

3 Likes

Awesome thank you @sunnyson

Awesome plugin! I wanted to run this on my other environments besides development. But I was curious why did you choose to just run it on development? I understand the security concerns of creating a weak admin user but having the script setup with environment variables I am planning on passing those into the running process in the other environments. Thoughts?

Hmm, yeah, I’ve limited it to dev env to avoid cases when someone forgets about it when migrating to prod. I will add tomorrow an extra env variable that will allow the plugin to be runned in any env.

In my case I use it only on dev, as all my local projects have the same credentials for faster development and seamless switching between projects. Also, I’ve added a button to VS code that adds the package automatically when clicking on it, if you want I can share it too. As it is very useful to create the Admin user in one click without typing yarn add strapi-plugin-bootstrap-admin-user.

@alexleone
I’ve added a new env variable: DEV_ADMIN_ALLOW. Set it to true to allow admin creation in any environment.
Update plugin to @latest version

Check here.

Awesome! I am going give it a try. Thanks for making the update!!

You should add it to GitHub - strapi/awesome-strapi: A curated list of awesome things related to Strapi

We do love pull requests to that repo and I am the one who reviews and merges them :wink: