User Identity Service Api (userstore)

Version: 0.9.1 (beta)

Supported client libraries: jQuery, AngularJS, Python

API Functions

new User({domain, token})

Service connector constructor. Takes all options to connect to the service.

Parameter

  • domain (optional): The subdomain name or fully qualified domain name. e.g ‘mydomain’ will be extended to ‘mydomain.nive.io’. The domain is only required for cross domain calls or in development mode.
  • token (optional): The security token returned by User.token() to authenticate the user. Browser based applications can also call User.signin() to retrieve the token as cookie to be handled automatically by the browser.

See Endpoints for API calls for all supported options.

The services name is fix and cannot be changed. The ‘name’ parameter is not supported.

var user = new nive.User({token: 'security token'});
if(user.authenticated()).done(function(data, message, jqXHR)    { user.name(); } );
// or
nive.User().name();

User.token({identity, password})

Retrieve a security token for the user. Either name or email or one of both allowed depending on identity policy. After obtaining the token it can be send in future requests to authenticate the user and perform secured actions.

Parameter

  • identity: the users name or email depending on identity settings
  • password: the users password

Return values

  • token: a JWT encoded string to be used in subsequent calls to authenticate the user. In case of failure the token is null.
  • message: (only set in case of failure) a status message returned by the server.

Status codes

  • 401 Authentication failed
  • 422 Parameter missing or invalid
nive.User().token({identity:'myname', password:'mypassword'})
  .done(function (data, message, xhr) {
    if(data.result) {
      var token=result.token;
      // use the token to get the current users name
      nive.User(token).name();
    }
  });
POST http://mydomain.nive.io/users/api/token
    Content-Type: application/json
    Body: {"identity": "myname", "password": "mypassword"}
=>
Status 200 {"token": ""}

User.signin({identity, password})

Signin the user with the credentials. Either name and/or email allowed depending on identity policy. This functions automatically sets a cookie with the security token to be handled by the browser. Use User.token() to handle the security token manually.

Parameter

  • identity: user name or email depending on configuration settings
  • password: the users password

Return values

  • result: true or false whether or not authentication succeeded. If authentication fails the status code is 401.
  • message: (only set in case of failure) status message returned by the server.

Status codes

  • 401 Authentication failed
  • 422 Parameter missing or invalid
nive.User().signin({identity:'myname', password:'mypassword'})
  .done(function (data, message, xhr) {
    if(data.result) $('#message').text('You have been signed in!');
    if(!data.result) $('#message').text('Failure: Please check your name and password!');
  });
POST http://mydomain.nive.io/users/api/signin
    Content-Type: application/json
    Body: {"identity": "myname", "password": "mypassword"}
=>
Status 200 {"result": "true"}

User.signout()

Invalidates the authentication cookie and signs the user out.

Return values

  • result: currently always true
nive.User().signout()
  .done(function (data, message, xhr) {
    $('#message').text('You have been signed out!');
  });
http://mydomain.nive.io/users/api/signout
=>
{"result": "true"}

User.identity()

Returns the identity, unique id and name of the authenticated user. Use User.name() as alternative to retrieve a reduced set of user identity information.

Return values

  • name: users signin name
  • email: the users email
  • id: unique identifier
  • realname: the users optional name field
nive.User().identity()
  .done(function (data, message, xhr) {
    $('#name').text(data.realname || data.name);
  });
GET http://mydomain.nive.io/users/api/identity
=>
{"name": "myname", "realname": "My Name", "email": "mymail@nive.co", "id": "cd345..."}

User.name()

Returns the users name or email depending on identity policy. Use User.identity() to retrieve all the users identity information.

Return values

  • identity: name or email depending on identity policy
  • realname: the users optional name field
nive.User().name()
  .done(function (data, message, xhr) {
    $('#name').text(data.realname || data.name);
  });
GET http://mydomain.nive.io/users/api/name
=>
{"name": "myname", "realname": "My Name" }

User.profile()

Returns the profile values of the currently authenticated user.

Return values

  • name: users signin name
  • email: the users email
  • realname: the users optional name field
  • data: custom user data
  • notify: email notification flag
  • activity: The start date and time of the previous session. The date is iso 8601 utc e.g ‘2014-10-21T16:54:21+00:00’.
  • id: unique identifier
nive.User().profile()
  .done(function (data, message, xhr) {
    $('#name').text(data.name);
    $('#email').text(data.email);
  });
GET http://mydomain.nive.io/users/api/profile
=>
{"name": "myname",
 "email": "myemail@nive.co",
 "realname": "My Name",
 "data": "custom user data",
 "activity": "2014/03/01 12:15:00",
 "notify": "true",
 "id": "da234553ed..."}

User.authenticated({groups})

Check the authentication state of the current user. If no ‘groups’ are passed the function returns if the user is signed in. If ‘groups’ is not empty the function returns if the user is assigned to at least one the groups.

Parameter

  • groups (optional): one or a list of groups

Return values

  • result: true or false

Status codes

  • 422 Invalid ‘groups’ parameter
nive.User().authenticated({groups:'mygroup'})
  .done(function (data, message, xhr) {
    if(!data.result)
      $('#message').text('You are not authenticated for mygroup');
  });
GET http://mydomain.nive.io/users/api/authenticated?groups=mygroup
=>
{"result": false}

User.allowed({permission})

Checks whether or not the current user has the given permission(s).

Parameter

  • permission (optional): one or multiple permissions

Return values

  • result: true or false. The result is true if the user has all permissions.
  • <permission name>: permission name pointing out if the user has this particular permission.
  • invalid: (only set in case of failure) points to invalid parameters transfered
  • message: (only set in case of failure) a status message returned by the server

Status codes

  • 422 Invalid ‘permission’ parameter
nive.User().allowed({permission:'updateEmail'})
  .done(function (data, message, xhr) {
    if(!data.result)
      $('#message').text('You are not allowed to update your email');
  });
POST http://mydomain.nive.io/users/api/allowed
    Content-Type: application/json
    {"permission":"updateEmail"}
=>
{"result": false, "updateEmail": false}

User.signupDirect({name, email, password, data})

Sign up a new user. The new user account is directly activated without verifying the email address or confirmation by the user adminstrator.

You can use the services permission settings in the backend to enable or disable the signup policy by allowing or removing the signupDirect permission.

Parameter

  • name: user sign in name. Depending on identity policy configuration settings the name can be omitted. minimum 3 characters, maximum 30 characters.
  • email: user email. Depending on identity policy configuration settings the email can be omitted.
  • password: the users password. minimum 5 characters, maximum 30 characters.
  • data (optional): additional data can be stored in a single field in json format (limited to 1000 bytes). To store json values convert it to string before submitting e.g. JSON.stringify(data)

Return values

In case of a failure the functions returns a status message and a list of invalid form fields if any. Invalid fields are referenced by name.

  • result: true or false whether or not the function succeeded
  • invalid: (only set in case of failure) points to invalid parameters transfered e.g. [["name", "required"], ["password", "required"]]
  • message: (only set in case of failure) a list of messages returned by the server e.g. ‘username_in_use’

Status codes

  • 413 Storage limits exceeded
  • 422 Invalid or missing parameter
nive.User().signupDirect({name:'myname', password:'mypassword', email:'myemail@nive.co'})
  .done(function (data, message, xhr) {
    if(data.result)
      $('#message').text('Done! Your account is ready to sign in.');
    else
      $('#message').text(data.messages);
  });
POST http://mydomain.nive.io/users/api/signupDirect
    Content-Type: application/json
    {"name":"myname", "password":"mypassword", "email":"myemail@nive.co"}
=>
{"result": "true"}

User.signupOptin({name, email, password, data})

Sign up a new user. The new user account is initially inactive and has to be activted in a second step. User.signupOptin() generates a token and sends it including a activation link to the email address of the new account.

The two required steps:

  1. Call this fuction to create the profile and send the activation token to the entered email address.
  2. Activate the new user profile by calling User.activate({token}) with the token as parameter.

Requires the Activation page url field to be set in the user identity service administration backend. The activation url will be passed to the email generator invoked by User.signupOptin().

You can use the services permission settings in the backend to enable or disable the signup policy by allowing or removing the signupOptin permission.

Parameter

  • name: user sign in name. Depending on identity policy configuration settings the name can be omitted. minimum 3 characters, maximum 30 characters.
  • email: user email. Depending on identity policy configuration settings the email can be omitted.
  • password: the users password. minimum 5 characters, maximum 30 characters.
  • data (optional): additional data can be stored in a single field in json format (limited to 1000 bytes). To store json values convert it to string before submitting e.g. JSON.stringify(data)

Return values

In case of a failure the functions returns a status message and a list of invalid form fields if any. Invalid fields are referenced by name.

  • result: true or false whether or not the function succeeded
  • invalid: (only set in case of failure) points to invalid parameters transfered e.g. [["name", "required"], ["password", "required"]]
  • message: (only set in case of failure) a list of messages returned by the server e.g. ‘username_in_use’

Status codes

  • 413 Storage limits exceeded
  • 422 Invalid or missing parameter
nive.User().signupOptin({name:'myname', password:'mypassword', email:'myemail@nive.co'})
  .done(function (data, message, xhr) {
    if(data.result)
      $('#message').text('Done! Check your email to complete the signup process.');
    else
      $('#message').text(data.messages);
  });
POST http://mydomain.nive.io/users/api/signupOptin
    Content-Type: application/json
    {"name":"myname", "password":"mypassword", "email":"myemail@nive.co"}
=>
{"result": "true"}

User.signupReview({name, email, password, data})

Sign up a new user. The new user account is initially inactive and has to be activted by the user administrator and optionally confirmed by email verification.

The required steps are:

  1. Call this function to create the profile and send the activation token to the entered email address.
  2. The user admin reviews the new profile and triggers the next step by calling User.review() with the appropriate action. If action is set to ‘optin’ a confirmation mail is send to the users email address including a activation token.
  3. In case of ‘optin’ a third step is required to finally activate the user. The token sent by email has to be processed by calling User.activate({token}) with the token as parameter.

See User.review() for details.

You can use the services permission settings in the backend to enable or disable the signup policy by allowing or removing the signupReview permission.

Parameter

  • name: user sign in name. Depending on identity policy configuration settings the name can be omitted. minimum 3 characters, maximum 30 characters.
  • email: user email. Depending on identity policy configuration settings the email can be omitted.
  • password: the users password. minimum 5 characters, maximum 30 characters.
  • data (optional): additional data can be stored in a single field in json format (limited to 1000 bytes). To store json values convert it to string before submitting e.g. JSON.stringify(data)

Return values

In case of a failure the functions returns a status message and a list of invalid form fields if any. Invalid fields are referenced by name.

  • result: true or false whether or not the function succeeded
  • invalid: (only set in case of failure) points to invalid parameters transfered e.g. [["name", "required"], ["password", "required"]]
  • message: (only set in case of failure) a list of messages returned by the server e.g. ‘username_in_use’

Status codes

  • 413 Storage limits exceeded
  • 422 Invalid or missing parameter
nive.User().signupReview({name:'myname',password:'mypassword',email:'myemail@nive.co'})
  .done(function (data, message, xhr) {
    if(data.result)
      $('#message').text('Done! Check your email to complete the signup process.');
    else
      $('#message').text(data.messages);
  });
POST http://mydomain.nive.io/users/api/signupReview
    Content-Type: application/json
    {"name":"myname", "password":"mypassword", "email":"myemail@nive.co"}
=>
{"result": "true"}

User.signupSendpw({name, email, data})

Sign up a new user. The new user account is initially activated but only accessible with the auto generated password send to the users email address.

You can use the services permission settings in the backend to enable or disable the signup policy by allowing or removing the signupSendpw permission.

Parameter

  • name: user sign in name. Depending on identity policy configuration settings the name can be omitted. minimum 3 characters, maximum 30 characters.
  • email: user email. Depending on identity policy configuration settings the email can be omitted.
  • data (optional): additional data can be stored in a single field in json format (limited to 1000 bytes). To store json values convert it to string before submitting e.g. JSON.stringify(data)

Return values

In case of a failure the functions returns a status message and a list of invalid form fields if any. Invalid fields are referenced by name.

  • result: true or false whether or not the function succeeded
  • invalid: (only set in case of failure) points to invalid parameters transfered e.g. [["name", "required"], ["password", "required"]]
  • message: (only set in case of failure) a list of messages returned by the server e.g. ‘username_in_use’

Status codes

  • 413 Storage limits exceeded
  • 422 Invalid or missing parameter
nive.User().signupSendpw({name:'myname',email:'myemail@nive.co'})
  .done(function (data, message, xhr) {
    if(data.result)
      $('#message').text('Done! Your password has been send by email.');
    else
      $('#message').text(data.messages);
  });
POST http://mydomain.nive.io/users/api/signupSendpw
    Content-Type: application/json
    {"name":"myname", "email":"myemail@nive.co"}
=>
{"result": "true"}

User.signupUid({email, password, data})

Sign up a new user. This function generates a random and unique 30 byte user name. The generated name is returned on success. If the identity policy is set to ‘name’ the email can be omitted and User.signupUid() can easily be used to handle automated machine/device accounts.

The new account is instantly activated.

You can use the services permission settings in the backend to enable or disable the signup policy by allowing or removing the signupUid permission.

Parameter

  • email: user email. Depending on identity policy configuration settings the email can be omitted.
  • password: the users password. minimum 5 characters, maximum 30 characters.
  • data (optional): additional data can be stored in a single field in json format (limited to 1000 bytes). To store json values convert it to string before submitting e.g. JSON.stringify(data)

Return values

In case of a failure the functions returns a status message and a list of invalid form fields if any. Invalid fields are referenced by name.

  • result: true or false whether or not the function succeeded
  • invalid: (only set in case of failure) points to invalid parameters transfered e.g. [["name", "required"], ["password", "required"]]
  • message: (only set in case of failure) a status message returned by the server e.g. ‘email_in_use’

Status codes

  • 413 Storage limits exceeded
  • 422 Invalid or missing parameter
nive.User().signupUid({password:'mypassword'})
  .done(function (data, message, xhr) {
    if(data.result)
      $('#message').text('Done! Account is ready.');
    else
      $('#message').text(data.messages);
  });
POST http://mydomain.nive.io/users/api/signupUid
    Content-Type: application/json
    {"password":"mypassword"}
=>
{"result": "true"}

User.activate({token})

Activate a new account by calling this function with the activation token sent to the new users email address. This function finally activates the users profile. The token is either generated by User.signupOptin() or User.review().

In general the token is passed as url parameter ‘token’ to the activation url. The activation url is configured in the backend or directly as part of the activation email template.

Parameter

  • token: the activation token sent by email to sign up mail address

Return values

  • result: true or false whether or not the function succeeded
  • message: (only set in case of failure) a status message

Status codes

  • 422 Invalid or missing parameter
nive.User().activate({token:'some-unreadable-token'})
  .done(function (data, message, xhr) {
    if(data.result)
      $('#message').text('Hurra! You can sign in now.');
    else
      $('#message').text(data.messages);
  });
POST http://mydomain.nive.io/users/api/activate
    Content-Type: application/json
    {"token":"some-unreadable-token"}
=>
{"result": "true"}

User.update({data, realname, notify})

Update a user profile with new values. Update can only be used for extended user data fields. To change one of ‘password’, ‘name’, ‘email’, ‘groups’ use one of the explicit functions.

Parameter

  • data (optional): additional data can be stored in a single field in json format (limited to 1000 bytes). To store json values convert it to string before submitting e.g. JSON.stringify(data)
  • realname (optional): optional name e.g to be used for display
  • notify (optional): a boolean value to activate or deactivate email notifications

Return values

In case of a failure the functions returns a status message and a list of invalid form fields if any. Invalid fields are referenced by name.

  • result: true or false whether or not the function succeeded
  • invalid: (only set in case of failure) points to invalid parameters transfered e.g. [["data", "too long"]]
  • message: (only set in case of failure) a status message returned by the server

Status codes

  • 422 Invalid or missing parameter
nive.User().update({realname: 'My Name',
                    notify: false,
                    data: JSON.stringify({custom: 'some value'})})
  .done(function (data, message, xhr) {
    if(data.result)
      $('#message').text('Done! Profile updated.');
    else
      $('#message').text(data.messages);
  });
POST http://mydomain.nive.io/users/api/update
    Content-Type: application/json
    {"realname":"My Name", "notify":false, "data": {"custom": "some value"}}
=>
{"result": "true"}

User.updatePassword({password, newpassword})

Update a users password. Authenticated users can change their password directly by sending their current password and a new one.

Parameter

  • password: the current password
  • newpassword: the new password. minimum 5 characters, maximum 30 characters.

Return values

  • result: true or false whether or not the function succeeded
  • invalid: (only set in case of failure) points to invalid parameters transfered e.g. [["newpassword", "too short"]]
  • message: (only set in case of failure) a status message returned by the server

Status codes

  • 422 Invalid or missing parameter
nive.User().updatePassword({password:'mypassword', newpassword:'secret'})
  .done(function (data, message, xhr) {
    if(data.result)
      $('#message').text('Done! Password updated.');
    else
      $('#message').text(data.messages);
  });
POST http://mydomain.nive.io/users/api/updatePassword
    Content-Type: application/json
    {"password":"mypassword", "newpassword":"secret"}
=>
{"result": "true"}

User.updateEmail({email})

Update the users email address. Unlike User.verifyEmail() this function updates the email of the authenticated user immediately without verification.

Parameter

  • email: the new email

Return values

  • result: true or false whether or not the function succeeded
  • invalid: (only set in case of failure) points to invalid parameters transfered e.g. [["email", "invalid_email"]]
  • message: (only set in case of failure) a status messages

Status codes

  • 422 Invalid or missing parameter
nive.User().updateEmail({email:'mynewmail@nive.co'})
  .done(function (data, message, xhr) {
    if(data.result)
      $('#message').text('OK! Please check your email.');
    else
      $('#message').text(data.messages);
  });
POST http://mydomain.nive.io/users/api/updateMail
    Content-Type: application/json
    {"email":"mynewmail@nive.co"}
=>
{"result": "true"}

User.verifyEmail({email})

Change the email address of a user after verifying the new email in a second step. User.verifyEmail() generates a token and sends it including a verification link to the new email address.

The two required steps:

  1. Call this fuction to trigger a varification email.
  2. Update the new email by calling User.verifyEmail2({token}) with the generated token as parameter.

Requires the Email verification page url set in user identity service administration backend. The url will be passed to the email generator invoked by User.verifyEmail().

Parameter

  • email: the new email

Return values

  • result: true or false whether or not the function succeeded
  • invalid: (only set in case of failure) points to invalid parameters transfered e.g. [["email", "invalid_email"]]
  • message: (only set in case of failure) a status messages

Status codes

  • 422 Invalid or missing parameter
nive.User().verifyEmail({email:'mynewmail@nive.co'})
  .done(function (data, message, xhr) {
    if(data.result)
      $('#message').text('OK! Please check your email.');
    else
      $('#message').text(data.messages);
  });
POST http://mydomain.nive.io/users/api/verifyEmail
    Content-Type: application/json
    {"email":"mynewmail@nive.co"}
=>
{"result": "true"}

User.verifyEmail2({token})

Activates the users new email address. The step requires the token generated and send to the users new email in the first step by User.verifyEmail().

Parameter

  • token: email verification token sent by email

Return values

  • result: true or false whether or not the function succeeded
  • message: (only set in case of failure) a status message

Status codes

  • 422 Invalid or missing parameter
nive.User().verifyEmail2({token:'some-token'})
  .done(function (data, message, xhr) {
    if(data.result)
      $('#message').text('Done! Email activated.');
    else
      $('#message').text(data.messages);
  });
POST http://mydomain.nive.io/users/api/verifyEmail2
    Content-Type: application/json
    {"token":"some-token"}
=>
{"result": "true"}

User.resetPassword({identity})

Triggers a reset password mail including a token by entering the uses identity. The password can be updated in a second step by calling User.resetPassword2({token, password}).

The two required steps:

  1. Call this fuction to trigger a reset password email.
  2. Update the password by calling User.resetPassword2({token, password}) with the generated token as parameter.

Requires the Reset password page url set in user identity service administration backend. The url will be passed to the email generator invoked by User.resetPassword().

Reset password can be used for not authenticated users if they have lost the password.

Parameter

  • identity: the users identity, email or name depending on configured identity policy

Return values

  • result: true or false whether or not the function succeeded
  • message: (only set in case of failure) a status message

Status codes

  • 422 Invalid or missing parameter
nive.User().resetPassword({identity:'myname'})
  .done(function (data, message, xhr) {
    if(data.result)
      $('#message').text('OK! Please check your email.');
    else
      $('#message').text(data.messages);
  });
POST http://mydomain.nive.io/users/api/resetPassword
    Content-Type: application/json
    {"identity":"myname"}
=>
{"result": "true"}

User.resetPassword2({token, newpassword})

The second step of the password reset process for not authenticated users. The step requires the token generated and send to the users email in the first step User.resetPassword().

In general the token is passed as url parameter ‘token’ to the reset password url. The url is configured in the backend or directly as part of the email template.

Parameter

  • token: password reset token sent by email
  • newpassword: the new password. minimum 5 characters, maximum 30 characters.

Return values

  • result: true or false whether or not the function succeeded
  • invalid: (only set in case of failure) points to invalid parameters transfered
  • message: (only set in case of failure) a status message

Status codes

  • 422 Invalid or missing parameter
nive.User().resetPassword2({token:'some-token', newpassword:'secret'})
  .done(function (data, message, xhr) {
    if(data.result)
      $('#message').text('Done! Password updated.');
    else
      $('#message').text(data.messages);
  });
POST http://mydomain.nive.io/users/api/resetPassword2
    Content-Type: application/json
    {"token":"some-token", "newpassword":"secret"}
=>
{"result": "true"}

User.message({message})

Enables the authenticated user to send a messages to the user administrator. A message can have up to 5000 characters and is send to the admins email address.

Parameter

  • message: the message to be send

Return values

  • result: true or false whether or not the function succeeded
  • message: (only set in case of failure) a status message

Status codes

  • 422 Invalid or missing parameter
nive.User().message()
  .done(function (data, message, xhr) {
    if(data.result)
      $('#message').text('OK! Done.');
    else
      $('#message').text('Something went wrong');
  });
POST http://mydomain.nive.io/users/api/message
    Content-Type: application/json
    {"message": "Hello! I'm new here."}
=>
{"result": "true"}

User.disable()

Disables the currently signed in user by setting the users state to ‘false’. The user is automatically signed out and prevented to sign in again. However the users data is not deleted or removed. The user administrator can still access and reactive the user in the management backend at any later time. To completely delete a user account use User.delete().

The users name and email are blocked and can not be used for new accounts.

Return values

  • result: true or false whether or not the function succeeded
nive.User().disable()
  .done(function (data, message, xhr) {
    if(data.result) $('#message').text('The user account has been disabled!');
  });
DELETE http://mydomain.nive.io/users/api/disable
=>
{"result": false}

User.delete()

Deletes the currently signed in user by completely removing the users profile. After deletion the account can not be restored again. User.delete() only affects data stored in the user database. Any other data owned by the user stored in other services are not altered.

After deletion the user name and email can be used for new user accounts again. Use User.disable() instead to make sure name and email can not be reused.

Return values

  • result: true or false whether or not the function succeeded
nive.User().delete()
  .done(function (data, message, xhr) {
    if(data.result) $('#message').text('The user account has been deleted!');
  });
DELETE http://mydomain.nive.io/users/api/delete
=>
{"result": true}

User.review({identity, action})

Note

Administration function!

Process a pending user signup. You can either accept, accept with email verification, activate, reject or disable the user. If rejected the users profile will be removed.

Actions

  • accept: Activates the user. Only triggered if the users state is pending and not active.
  • optin: Sends a verification mail to the users email address. The user is activated after confirmation.
  • activate: Activates the user. Unlike ‘accept’ this can also be used for inactive users.
  • reject: Removes a pending user from the user database.
  • disable: Disables the user account or removes pending state if already inactive.

The ‘optin’ action requires the Activation page url set in user identity service administration backend. The activation url will be passed to the email generator invoked by User.review().

Parameter

  • identity: the users identity
  • action: ‘accept’, ‘optin’, ‘activate’, ‘disable’ or ‘reject’

Return values

  • result: true or false whether or not the function succeeded
  • message: (only set in case of failure) a status message

Status codes

  • 422 Invalid or missing parameter
nive.User().review({identity: 'user1', action: 'accept'})
  .done(function (data, message, xhr) {
    if(data.result)
      $('#message').text('OK! Done.');
    else
      $('#message').text('Something went wrong');
  });
POST http://mydomain.nive.io/users/api/review
    Content-Type: application/json
    {"identity": "user1", "action": "accept"}
=>
{"result": "true"}

User.getUser({identity})

Note

Administration function!

Retrieve the users identity, data and state.

Parameter

  • identity: identity of the user

Return values

  • name
  • email
  • realname
  • notify
  • data
  • activity
  • id
  • groups
  • token
  • active
  • pending

Status codes

  • 422 Invalid or missing parameter
nive.User().getUser({identity:'user1'})
  .done(function (data, message, xhr) {
    if(data) {
      $('#name').text(data.name);
      // ...
    }
  });
POST http://mydomain.nive.io/users/api/getUser
    Content-Type: application/json
    {"identity": "user1"}
=>
{... profile values ...}

User.setUser({identity, values})

Note

Administration function!

Update the users profile values. Full access to the users values, state and security groups.

Parameter

  • identity: identity of the user
  • values: profile values to be updated. Omitted fields remain unchanged. Fields: ‘email’, ‘realname’, ‘notify’, ‘data’, ‘pending’, ‘active’, ‘activity’, ‘token’, ‘groups’

Return values

  • result: true or false whether or not the function succeeded
  • invalid: (only set in case of failure) points to invalid parameters
  • message: (only set in case of failure) a status message returned by the server

Status codes

  • 422 Invalid or missing parameter
nive.User().setUser({identity:'user1', values: {active: false}})
  .done(function (data, message, xhr) {
    if(data.result) $('#message').text('The users profile has been updated!');
  });
POST http://mydomain.nive.io/users/api/setUser
    Content-Type: application/json
    {"identity": "user1", "values": {"active": "false"}}
=>
{"result": true}

User.removeUser({identity})

Note

Administration function!

Deletes the user by completely removing the users profile. After deletion the account can not be restored again. This only affects data stored in the user database. Any other data owned by the user stored in other services are not altered.

After deletion the user name and email can be used for new user accounts again. Use User.setUser() with active set to ‘false’ instead to make sure name and email can not be reused.

Parameter

  • identity: the users identity

Return values

  • result: true or false whether or not the function succeeded
  • message: (only set in case of failure) a status message returned by the server

Status codes

  • 422 Invalid or missing parameter
nive.User().removeUser({identity: 'user1'})
  .done(function (data, message, xhr) {
    if(data.result) $('#message').text('The user account has been deleted!');
  });
POST http://mydomain.nive.io/users/api/removeUser
    Content-Type: application/json
    {"identity": "user1"}
=>
{"result": true}

User.list({active, pending, start})

Note

Administration function

Lists user profiles by a variety of search parameters. See also User.identities().

Parameter

  • active: empty, true or false.
  • pending: empty, true or false.
  • sort: field to sort the result by ‘id’, ‘name’, ‘email’, ‘realname’, ‘activity’
  • order: < or > to sort ascending or descending
  • size: result batch size. max 100.
  • start: batch result start number

Return values

  • users: list including ‘name’, ‘email’, ‘realname’, ‘pending’, ‘active’, ‘id’, ‘activity’ for each user
  • start: batch start
  • size: batch size
  • invalid: (only set in case of failure) points to invalid parameters
  • message: (only set in case of failure) a status message returned by the server

Status codes

  • 422 Invalid or missing parameter
nive.User().list({"pending": true})
  .done(function (data, message, xhr) {
    if(data.size) $('#message').text('Pending user reviews found!');
  });
POST http://mydomain.nive.io/users/api/list
    Content-Type: application/json
    {"active": true}
=>
{"users": [...], "start": 1, size: 1}

User.identites({active, pending, start})

Note

Administration function!

Lists user identities by a variety of search parameters. See also User.list().

Parameter

  • active: empty, true or false.
  • pending: empty, true or false.
  • sort: field to sort the result by ‘id’, ‘name’, ‘email’, ‘realname’, ‘activity’
  • order: < or > to sort ascending or descending
  • size: result batch size. max 100.
  • start: batch result start number

Return values

  • users: list including ‘name’ or ‘email’, ‘id’ for each user
  • start: batch start
  • size: batch size
  • invalid: (only set in case of failure) points to invalid parameters
  • message: (only set in case of failure) a status message returned by the server

Status codes

  • 422 Invalid or missing parameter
nive.User().identities({"pending": true})
  .done(function (data, message, xhr) {
    if(data.size) $('#message').text('Pending user reviews found!');
  });
POST http://mydomain.nive.io/users/api/identities
    Content-Type: application/json
    {"active": true}
=>
{"users": [...], "start": 1, size: 1}

User.getPermissions()

Note

Administration function!

Retrieve all permissions and assigned groups of this service. The result contains a list of permission and groups items.

[
    {permission: "signupDirect", groups: ["sys:noone"]},
    {permission: "signupReview", groups: ["sys:everyone"]},
    ...
]

Return values

The function returns a permission:name, groups:list item for each permission. [{permission:name, groups:list}, ...]

  • permission: the permissions name
  • groups: a list of assigned groups

Status codes

  • 422 Invalid or missing parameter
---
---

User.setPermissions({permissions})

Note

Administration function!

Update a single or multiple service permissions. Each permission to be updated must include the name, one or multiple groups and a action: ‘add’ (default), ‘replace’, ‘revoke’.

[
    {permission: "signupDirect", groups: ["sys:noone"], action: "replace"},
    {permission: "signupReview", groups: ["sys:everyone"], action: "revoke"},
    ...
]

Parameter

for each permission

  • permission: permission name to be updated
  • groups: groups to be added, revoked or set depending on action
  • action: ‘add’, ‘replace’, ‘revoke’

Return values

  • result: true or false whether or not the function succeeded
  • message: (only set in case of failure) a status message returned by the server

Status codes

  • 422 Invalid or missing parameter
---
---

User.ping({fake})

Simple test and health check function.

Parameter

  • fake: fake http response status e.g. 422

Return values

  • result: true if ‘fake’ is empty or 200 otherwise false
nive.User().ping()
  .done(function (data, message, xhr) {
    $('#message').text('Seems alive!');
  });
GET http://mydomain.nive.io/users/api/ping
    Content-Type: application/json
    {"active": true}
=>
{"result": 1}