

Creating admin accounts in DotKernel API
source link: https://www.dotkernel.com/how-to/creating-admin-accounts-in-dotkernel-api/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Creating admin accounts in DotKernel API
Starting from v3, DotKernel API introduces support for admin accounts. In this article we will describe two different methods of creating an admin account.
Method 1: Using API endpoint
This action can be performed only by an authenticated admin/superuser.
Once authenticated call the protected endpoint POST /admin
with the following JSON body:
{ "identity": "{IDENTITY}", "password": "{PASSWORD}", "passwordConfirm": "{PASSWORD}", "firstname": "{FIRSTNAME}", "lastname": "{LASTNAME}", "roles": [ { "uuid": "{ROLE_UUID}" } ] }
after replacing:
- {IDENTITY} with a valid username OR email address
- {PASSWORD} with a valid password
- {ROLE_UUID} with a valid admin role UUID (You can get a list of admin roles by calling the protected endpoint
GET /admin/role
) - {FIRSTNAME} and {LASTNAME} are optional
NOTE: You can specify multiple admin roles under the roles key.
If the submitted data is valid, the response will be similar to the below:
{ "uuid": "d436b044-be36-11eb-9eb1-78f29ef45f43", "identity": "Letha_Runolfsson96", "firstName": "Oswald", "lastName": "Swift", "status": "active", "roles": [ { "uuid": "eaa3d01c-9fc0-11eb-b099-78f29ef45f43", "name": "admin", "created": { "date": "2021-04-17 23:07:27.000000", "timezone_type": 3, "timezone": "Europe/Berlin" }, "updated": null } ], "created": { "date": "2021-05-26 17:27:06.194613", "timezone_type": 3, "timezone": "Europe/Berlin" }, "updated": { "date": "2021-05-26 17:27:06.279705", "timezone_type": 3, "timezone": "Europe/Berlin" }, "_links": { "self": { "href": "http://localhost:8080/admin/d436b044-be36-11eb-9eb1-78f29ef45f43" } } }
The new admin account is ready to use.
Method 2: Using terminal command
Run the following command in your application’s root directory:
php ./bin/cli.php admin:create -i {IDENTITY} -p {PASSWORD}
php ./bin/cli.php admin:create --identity {IDENTITY} --password {PASSWORD}
after replacing:
- {IDENTITY} with a valid username OR email address
- {PASSWORD} with a valid password
NOTE:
- if the specified identity or password contain special characters, make sure you surround them with double quote signs
- this method does not allow specifying an admin role – newly created accounts will have role of admin
If the submitted data is valid, the outputted response is:
Admin account has been created.
The new admin account is ready to use.
You can get more help with this command by running:
php ./bin/cli.php help admin:create
Leave a Reply Cancel Reply
Your email address will not be published. Required fields are marked *
You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
Save my name, email, and website in this browser for the next time I comment.
Recommend
-
6
containersDotKernel is built around the PSR-11 dependency container. We have chosen
-
1
Dotkernel Admin version 3 launched – DotKernel PSR-7 Middleware Applications Posted by admin on July 30, 2020 |
-
7
Doctrine caching in DotKernel Using an ORM in production without any sort of cache strategy is a very bad move. The Database server chokes; lots of CPU cycles wasted only to generate metadata an...
-
9
Posted by Merlin on April 28, 2021 | 1 Comment...
-
3
Using Postman documentation in DotKernel API 3 Starting from version 3.0 DotKernel API provides it’s documentation using Postman. In this article we will go into the details of crea...
-
5
Posted by Merlin on June 29, 2021 | No Comments
-
3
Dotkernel Frontend version 3 launched – DotKernel PSR-7 Middleware Applications Posted by admin on May 19, 2020 |
-
7
Posted by SergiuB on July 18, 2022 |
-
6
Posted by kakapiciu on July 27, 2022 |
-
7
DotKernel API: architecture and components Based on Enrico Zimuel’s Zend Expressive API – Skeleton example, DotKernel API runs on
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK