Creating users

From DreamFactory
Jump to: navigation, search
DreamFactoryTutorialsCreating users
(Example - Creating an Admin)
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
=== Tutorial ===
+
There are two types of users in a DreamFactory instance: Admins and Users (non-admins). Admins use the API api/v2/system/admin. Users are part of the df-user (https://github.com/dreamfactorysoftware/df-user) package
 +
and use the API api/v2/system/user.
  
There are two types of users in a DreamFactory 2.0 instance - Admins and Users (non-admins). Admins are part of system and
+
This tutorial demonstrates how to create Admins and Users using the DreamFactory Admin Console and by using
uses the API api/v2/system/admin. Users are part of the df-user (https://github.com/dreamfactorysoftware/df-user) package
+
API endpoints directly.  
and uses the API api/v2/system/user. This tutorial will go over creating both Admins and Users using admin console as well as the  
+
API endpoints.  
+
  
 
=== Creating Admins ===
 
=== Creating Admins ===
Line 30: Line 29:
  
  
    ''Note: Session token can also be supplied using X-DreamFactory-Session-Token request header.''
+
'''''Note:''' Session token can also be supplied using X-DreamFactory-Session-Token request header.''
  
 
==== Example - Creating an Admin ====
 
==== Example - Creating an Admin ====
Line 51: Line 50:
 
* Request URL:
 
* Request URL:
 
<pre>POST https://foo.com/api/v2/system/admin?session_token=abc.123.efg</pre>
 
<pre>POST https://foo.com/api/v2/system/admin?session_token=abc.123.efg</pre>
 
  
 
=== Creating Users ===
 
=== Creating Users ===
  
 
Log into the admin console and click on the 'Users' tab. From there click on the 'Create' button from the left menu. Fill out  
 
Log into the admin console and click on the 'Users' tab. From there click on the 'Create' button from the left menu. Fill out  
the new user form and click on the 'Create' form button. You can send out an email invitation to the new user by checking off
+
the new user form and click on the 'Create' form button. You can send out an email invitation to the new user by checking  
the 'Send Email Invitation' checkbox before creating the user. If you send out email invitation then there is no need to  
+
the 'Send Email Invitation' checkbox before creating the user. If you send out email invitation, there's no need to  
manually set the password as the user will create his/her own password using the invitation email. You need to be an admin  
+
manually set the password since the user will create his/her own password using the invitation email. You need to be an admin  
or a user with role-service access to 'POST api/v2/system/user' API to create another user.
+
or a user with role-service access to <code>POST api/v2/system/user</code> API to create another user.
  
 
==== API Endpoints  ====
 
==== API Endpoints  ====
Line 99: Line 97:
  
  
    ''Note: Session token can also be supplied using X-DreamFactory-Session-Token request header.''
+
'''''Note:''' Session token can also be supplied using X-DreamFactory-Session-Token request header.''
  
==== Example - Creating an User  ====
+
==== Example - Creating a User  ====
  
 
===== With email invitation: =====
 
===== With email invitation: =====

Latest revision as of 16:41, 15 July 2016

There are two types of users in a DreamFactory instance: Admins and Users (non-admins). Admins use the API api/v2/system/admin. Users are part of the df-user (https://github.com/dreamfactorysoftware/df-user) package and use the API api/v2/system/user.

This tutorial demonstrates how to create Admins and Users using the DreamFactory Admin Console and by using API endpoints directly.

Creating Admins

Log into the admin console and click on the 'Admins' tab. From there click on the 'Create' button from the left menu. Fill out the new admin form and click on the 'Create' form button. You must be an admin to create another admin account.

API Endpoint

POST https://{url}/api/v2/system/admin?session_token={jwt_for_an_admin_session}

Request body:

{
  "resource": [
    {
      "name": "display_name",           //Required field
      "first_name": "user_first_name",
      "last_name": "user_last_name",
      "email": "email_address",         //Required field
      "password": "password"
    }
  ]
}


Note: Session token can also be supplied using X-DreamFactory-Session-Token request header.

Example - Creating an Admin

  • Session Token: abc.123.efg
  • Request body:
{
  "resource": [
    {
      "name": "John",
      "first_name": "John",
      "last_name": "Doe",
      "email": "jdoe@example.com",
      "password": "secret"
    }
  ]
}
  • Request URL:
POST https://foo.com/api/v2/system/admin?session_token=abc.123.efg

Creating Users

Log into the admin console and click on the 'Users' tab. From there click on the 'Create' button from the left menu. Fill out the new user form and click on the 'Create' form button. You can send out an email invitation to the new user by checking the 'Send Email Invitation' checkbox before creating the user. If you send out email invitation, there's no need to manually set the password since the user will create his/her own password using the invitation email. You need to be an admin or a user with role-service access to POST api/v2/system/user API to create another user.

API Endpoints

With email invitation:
POST https://{url}/api/v2/system/user?send_invite=true&session_token={jwt_for_an_user_session_with_proper_role}

Request body:

{
  "resource": [
    {
      "name": "display_name",           //Required field
      "first_name": "user_first_name",
      "last_name": "user_last_name",
      "email": "email_address"          //Required field
    }
  ]
}
Without email invitation:
POST https://{url}/api/v2/system/user?session_token={jwt_for_an_user_session_with_proper_role}

Request body:

{
  "resource": [
    {
      "name": "display_name",           //Required field
      "first_name": "user_first_name",
      "last_name": "user_last_name",
      "email": "email_address",         //Required field
      "password": "password"
    }
  ]
}


Note: Session token can also be supplied using X-DreamFactory-Session-Token request header.

Example - Creating a User

With email invitation:
  • Session Token: abc.123.efg
  • Send Invite: true
  • Request Body:
{
  "resource": [
    {
      "name": "John",
      "first_name": "John",
      "last_name": "Doe",
      "email": "jdoe@example.com"
    }
  ]
}
  • Request URL:
POST https://foo.com/api/v2/system/user?send_invite=true&session_token=abc.123.efg


Without email invitation:
  • Session Token: abc.123.efg
  • Request Body:
{
  "resource": [
    {
      "name": "John",
      "first_name": "John",
      "last_name": "Doe",
      "email": "jdoe@example.com",
      "password": "secret"
    }
  ]
}
  • Request URL:
POST https://foo.com/api/v2/system/user?session_token=abc.123.efg