Skip to content

Latest commit

 

History

History
179 lines (142 loc) · 4.1 KB

USER_MANAGEMENT.md

File metadata and controls

179 lines (142 loc) · 4.1 KB

User Management

You can manage user with APIs user. Uiza have 2 levels of user

  • Admin - This account will have the highest priority, can have permission to create & manage users.

  • User - This account level is under Admin level. It only manages APIs that relates to this account.

See details here.

Retrieve an user

Retrieves the details of an existing user. You need only supply the unique userId that was returned upon user creation.

See details here.

const uiza = require('uiza');
uiza.authorization('your-authorization-key');
uiza.app_id('your-app-id');

const params = {
  'id': '03e6a059-c6d2-440c-a653-1e309918c792'
};

uiza.user.retrieve(params)
  .then((res) => {
    // Identifier of user
  }).catch((err) => {
    //Error
  });

Example Response

{ 
  id: '55ff6888-55b7-4d5b-b090-b5b3ad511fe7',
  isAdmin: 1,
  username: 'user_test',
  email: '[email protected]',
  avatar: 'https://exemple.com/avatar.jpeg',
  fullName: 'User Test',
  updatedAt: '2019-02-28T02:06:56.000Z',
  createdAt: '2019-02-28T02:06:56.000Z',
  status: 1
}

List all users

Returns a list of your user. The users are returned sorted by creation date, with the most recent user appearing first.

If you use Admin token, you will get all the user. If you use User token, you can only get the information of that user

See details here.

const uiza = require('uiza');
uiza.authorization('your-authorization-key');
uiza.app_id('your-app-id');

uiza.user.list().then((res) => {
  //Get list of user including all detail.
}).catch((err) => {
  //Error
});

Example Response

[
  { id: 'f3421298-d2c5-4cef-8245-30111b03d1d6',
    isAdmin: 0,
    username: 'ef1f5b77-617a-49ac-9562-35a87d3821d4',
    email: '[email protected]',
    avatar: 'https://static.uiza.io/uiza_logo_128.png',
    fullName: 'ecfd28e5-0c87-41b1-a32d-fce2e741d9cd',
    updatedAt: '2019-02-27T00:00:00.000Z',
    createdAt: '2019-02-27T08:18:24.000Z',
    status: 1 },
  { id: '9e4df7c2-111d-4107-9c2e-6d2cb13c06f0',
    isAdmin: 0,
    username: 'user_test002',
    email: '[email protected]',
    avatar: 'https://exemple.com/avatar.jpeg',
    fullName: 'User Test',
    updatedAt: '2019-02-26T09:12:26.000Z',
    createdAt: '2019-02-26T09:12:26.000Z',
    status: 1
  }
]

Update an user

Updates the specified user by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

See details here.

const uiza = require('uiza');
uiza.authorization('your-authorization-key');
uiza.app_id('your-app-id');

const params = {
  'id': '9e4df7c2-111d-4107-9c2e-6d2cb13c06f0',
  'status': 0,
  'name': 'user_test_110',
  'avatar': 'https://exemple.com/avatar.jpeg',
  'dob': '2018-10-05',
};

uiza.user.update(params).then((res) => {
  // Identifier of user wanted to update
}).catch((err) => {
  //Error
});

Example Response

{ id: '9e4df7c2-111d-4107-9c2e-6d2cb13c06f0' }

Update password

Update password allows Admin or User update their current password.

See details here.

const uiza = require('uiza');
uiza.authorization('your-authorization-key');
uiza.app_id('your-app-id');

const params = {
  'userId': '263bbbb8-c0c9-4e1f-9123-af3a3fd46b80',
  'oldPassword': 'FMpsr<4[dGPu?B#u',
  'newPassword': 'S57Eb{:aMZhW=)G$'
};

uiza.user.change_password(params).then((res) => {
  // Identifier of user has been reset password
}).catch((err) => {
  //Error
});

Example Response

{ result: 'ok' }

Log Out

This API use to log out an user. After logged out, token will be removed.

See details here.

const uiza = require('uiza');
uiza.authorization('your-authorization-key');
uiza.app_id('your-app-id');

uiza.user.log_out()
  .then((res) => {
    // Identifier of task publish
  }).catch((err) => {
    //Error
  });

Example Response

{
  message: 'Logout success',
  code: 200,
  type: 'SUCCESS'
}