VivochaLogin

Vivocha Agent Login Library

Methods

(async) ready(VivochaLoginOptionsopt) → {Promise|Promise}

This function, resolving the returned Promise, signals that the Vivocha Library is fully loaded, initialized and ready to be used. Until the returned promise is resolved, not other Vivocha function is safe to be used. Overrides VivochaCore.ready and extends it to allow the automatic login of an Agent. See VivochaAgent.login for more details on the login procedure.

Parameters:
Name Type Attributes Description
VivochaLoginOptions VivochaLoginOptions <optional>

Agent credentials or JSON Web Token.

Properties
Name Type Attributes Description
jwt string <optional>

JSON Web Token.

uid string <optional>

Userid of the Agent to login or of the superuser acting on behalf of an Agent.

pwd string <optional>

Agent password or password of the superuser acting on behalf of the an Agent.

onBehalfOf string <optional>

If acting on behalf of an Agent, Userid of the Agent.

Returns:
  • The login request succeeds if the promise is resolved.

    Type
    Promise
  • Type
    Promise

(async) login(VivochaLoginOptionsopt) → {Promise}

Creates a login session for an Agent. The function the be used in two different ways:

  • Passing the Userid and the password of the agent to login;
  • Using the credentials of an administrator acting on behalf of an Agent
Examples
vivocha.ready().then(function() {
  // The API is ready
  vivocha.login({jwt: 'TOKEN_HERE'}).then(function() {
    // Agent session created, all systems go.
  });
});
vivocha.ready().then(function() {
  // The API is ready
  vivocha.login({uid: 'agent', pwd: 'password'}).then(function() {
    // Agent session created, all systems go.
  });
});
Parameters:
Name Type Attributes Description
VivochaLoginOptions VivochaLoginOptions <optional>

Agent credentials or JSON Web Token.

Properties
Name Type Attributes Description
jwt string <optional>

JSON Web Token.

uid string <optional>

Userid of the Agent to login or of the superuser acting on behalf of an Agent.

pwd string <optional>

Agent password or password of the superuser acting on behalf of the an Agent.

onBehalfOf string <optional>

If acting on behalf of an Agent, Userid of the Agent.

Returns:

The login request succeeds if the promise is resolved.

Type
Promise

(async) logout() → {Promise}

Logs out the currently logged in Agent

Returns:

Resolved when the operation is successfully completed.

Type
Promise