How To Dev - Example of Registering a New User via Mobile App

×

Warning message

  • You can't delete this newsletter because it has not been sent to all its subscribers.
  • You can't delete this newsletter because it has not been sent to all its subscribers.

 

POST https://www.snap4city.org/drupal/api/user/register

ContentType: application/json

Accept: application/json

{

       "name": "John.Doe",

       "mail": "jdoe@me.com",

       "legal_accept": "true",

       "extras-1": "true",

       "extras-2": "true",

       "og_user_node": { "und": [{ "default":"722" }] }

}

// note that:

722 = Organization is “Greece-UNISYSTEMS”

319 = Organization is “DISIT

Etc.

 

Return 200 if user can be registered, an email is sent to the user to finish registration on the server (set password) the result is:

{   "uid": "8005",

    "uri": "https://www.snap4city.org/drupal/api/user/8005"

}

 

Return 406 in case of error like existing username or existing email address.

{ "form_errors": {

  "name": "The name <em class=\"placeholder\">p.bellini</em> is already taken."

    }

}

This approach can be used to register the new user from a mobile or Web App. In any case, the finalization of the registration will have to be performed (on the basis of the links received on the email address provided) on the Portal (in general case on snap4city.org, or other snap4tech platform from which the registration is requested). This two steps registration is a minimal secure practice.

It has no sense to provide the possibility of setting a password in one shot via an API only by knowing a user ID, since it would allow to any user to change the password of any other users.

Once the registration is finalized on the portal providing a preferred password, the user can enter in the mobile App with the credentials, and the mobile App can use the following functionalities to get Access Token to send data messages on broker via NGSI V1/V2, as well as to get data from smart city API.

 

 

 

How To Dev - Example of Registering a New User via Mobile App | Snap4City

Error

×

Error message

  • Unable to send e-mail. Contact the site administrator if the problem persists.
  • Unable to send e-mail. Contact the site administrator if the problem persists.
  • Unable to send e-mail. Contact the site administrator if the problem persists.
  • Notice: Trying to get property of non-object in user_is_logged_in() (line 1576 of /var/www/html/drupal/modules/user/user.module).
  • Notice: Trying to get property of non-object in user_is_logged_in() (line 1576 of /var/www/html/drupal/modules/user/user.module).
  • Notice: Trying to get property of non-object in og_field_access() (line 578 of /var/www/html/drupal/sites/default/modules/og/og.module).
  • Notice: Trying to get property of non-object in user_access() (line 806 of /var/www/html/drupal/modules/user/user.module).
  • Notice: Trying to get property of non-object in user_access() (line 818 of /var/www/html/drupal/modules/user/user.module).
  • Notice: Trying to get property of non-object in user_access() (line 819 of /var/www/html/drupal/modules/user/user.module).
  • Notice: Trying to get property of non-object in user_access() (line 825 of /var/www/html/drupal/modules/user/user.module).
  • Notice: Trying to get property of non-object in user_access() (line 828 of /var/www/html/drupal/modules/user/user.module).
  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/drupal/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/drupal/includes/bootstrap.inc).
  • Error: __clone method called on non-object in og_user_access_entity() (line 2249 of /var/www/html/drupal/sites/default/modules/og/og.module).
The website encountered an unexpected error. Please try again later.