users service

Adds user-management capabilities to Tymly (e.g. authorization checks, what flows/forms a user is entitled to instigate etc.). This service is provided via the tymly plugin and isn't offered by any of the other core plugins.

Boot config

{
  "defaultUsers": {
    "Dave": [
      "fbotTest_fbotTestAdmin"
    ],
    "Steve": [
      "spaceCadet"
    ]
  }
}
Property Type Description Required
defaultUsers object Ensures a list of users are available at boot-time. An object of key/value pairs where the key is a username and the value is an array of role names that should be assigned to it. No

Service methods/properties

ensureUserRoles

Ensures that the specified user has been assigned the specified roles

Parameters

  • userId string A userId for which the provided roles will be assigned to
  • roleIds Array<string> An array of roleIds that should be assigned to the user
  • callback Function Called with a standard error

Examples

users.ensureUserRoles(
  'Dave',
  ['fbotTest_fbotTestAdmin'],
  function (err) {
    // Expect err to be null
  }
)

Returns undefined

getUserRoles

Returns with all the roles currently assigned to the specified userId

Parameters

  • userId string Specifies which useId to return a list of roles for
  • callback Function Called with an array of roleId strings that are assigned to the specified userId

Examples

users.getUserRoles(
  'Dave',
  function (err, roles) {
    // roles === ['fbotTest_fbotTestAdmin']
  }
)

Returns undefined

resetCache

Resets the internal cache of users and their roles. Needs calling if things change in the fbot_roleMembership_1_0 model and similar.

Examples

users.getUserRoles(
  'Dave',
  function (err, roles) {
    // roles === ['fbotTest_fbotTestAdmin']
  }
)

Returns undefined

calculateRemitForUser

Returns a list of state-machines a user has the correct credentials to start, along with any form-definitions they can interact with. Useful for client apps wanting to configure themselves around an individual.

Parameters

  • userId string Specifies which useId to return a remit-object for
  • callback Function Called with a ‘remit’ object

Examples

users.calculateRemitForUser(
  'Dave',
  function (err, remit) {
    // remit is an object:
    //  stateMachinesUserCanStart: []
    //  forms: {}
  }
)

Returns undefined


Boots after

caches statebox rbac