2

Creating admin accounts in DotKernel API

 2 years ago
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.
Posted by Merlin on July 9, 2021 | No Comments

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 *

Comment

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>

Name *
Email *
Website

Save my name, email, and website in this browser for the next time I comment.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK