Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

User Management

Joskowski Andrzej edited this page Apr 8, 2015 · 16 revisions

This API handles Users

Create a User

Create user - user is a prerequisite for all system usages. After creating user you will be able to perform actions like account creation, updating your user attributes and other.

User can be created only using Dashboard because of recaptcha requirements. Fill in form with email, password and accept Terms and Conditions. After user activation via link in email sent, you should be able to retrieve userId using /auth/me route.

Get User information

Param Type Description Value
Authorization HTTP Header Access Token Authorization: Bearer eyJ0eX...
userId URL Slug The ID of a user. This was returned when the user was created. If you don't have the userId but have user credentials, you can obtain an Authorization Token and then get the Authorization Token Info. The UserId will be the subject of the token payload. If the result body were converted to a JavaScript object, the userId would be at result["payload"]["sub"] 53e95985c8406a147700b94d
Request
GET /users/{userId}

Response* 200 OK (application/json)
{
    "id":"53e95985c8406a147700b94d",
    "accounts":{
        "e5d969cd-e7fa-404e-a1e5-f4ce138f62c3":{
            "name":"Group1_Account",
            "role":"admin",
            "healthTimePeriod":86400
        }
    },
    "attributes":{
        "phone":"123456789",
        "another_attribute":"another_value"
    },
    "email":"test@example.com",
    "termsAndConditions":true,
    "verified":true
}

*Response won't contain "accounts" key if user did not create any account nor accept any invitation.


Update user attributes

As an user, you can add attributes to your user data. Attributes can be any : pairs.

Param Type Description Value
Authorization HTTP Header Access Token Authorization: Bearer eyJ0eX...
Content-Type HTTP Header Type of body content application/json
userId URL Slug The ID of an User 53e95985c8406a147700b94d
Request
PUT /users/{userId}
{   
   "attributes":{
        "phone":"123456789",
        "another_attribute":"another_value",
        "new":"next_string_value"
    }
}
Response 200

Delete a User

Delete a User. This action will result in deleting your user data, and also accounts if they do not have any other administrators. You will also no longer be able to use your old token.

Param Type Description Value
Authorization HTTP Header Access Token Authorization: Bearer eyJ0eX...
userId URL Slug The ID of a User 53e95985c8406a147700b94d
Request
DELETE /users/{userId}

Response 204

Change forgotten password

In order to change password (for cases in which user do not remember the old one) you have to do following steps:

  1. Invoke POST /users/forgot_password. After this step user will receive email with a url, which can be used to set a new password via IoT Dashboard. In email there will be user's token as a part of resetPassword url. Token is required for successful completion of next steps. Token is unique for user and action.
  2. Invoke PUT /users/forgot_password, with token from email received by user after completion of point 1. In a request body you have to put new password and token.

Details of methods described above:

Request change password

Methods generate and send email, which can be used to change password. User email has to be specified in request body.

Param Type Description Value
Content-Type HTTP Header Type of body content application/json
Request
POST /users/forgot_password
{
    "email":"test@example.com"
}

Response 200

Update password

Method set new password for the user. In request body you have put token received in a email (send after invoking POST /users/forgot_password) and the new password.

Param Type Description Value
Content-Type HTTP Header Type of body content application/json
Request
PUT /users/forgot_password
{
   "token":"ki2pc9RdnVVSKoN4",
   "password":"Qwerty2"
}

Response 200

Change password

Methods set new password for a user (identified by email).

Param Type Description Value
Authorization HTTP Header Access Token Authorization: Bearer eyJ0eX...
Content-Type HTTP Header Type of body content application/json
email URL Slug The email of an User test@example.com
Request
PUT /users/{email}/change_password
{
    "currentpwd": "Qwerty1",
    "password": "Qwerty2"
}

Response 200

Request user verification

Methods generate and send email, which can be used to activate user. User email has to be specified in request body.

Param Type Description Value
Content-Type HTTP Header Type of body content application/json
Request
POST /users/request_user_verification
{
    "email":"test@example.com"
}

Response 200