Core
Framework v2.x
2

users() #

Available since 2.14.0

Loads users into the app.

This method is idempotent. If a user is defined multiple times before the app starts with the same kuid, only the last one will be retained.

This method can only be used before the application is started.

users(
  users: JSONObject,
  options?: {
    onExistingUsers?: 'overwrite' | 'skip'
  }
): void

ArgumentTypeDescription
users
JSONObject
Object containing users and their definitions.
onExistingUsers
[overwrite, skip]
Default to skip. Strategy to adopt when trying to import an already existing user.

onExistingUsers option applies globally for every user import even when not given in this specific call.

Usage #

app.import.users({
  kuidA: {
    content: {
      profileIds: ['profileA', 'profileB'],
      name: 'foo'
    },
    credentials: {
      local: { username: 'bar', password: 'foobar' }
    }
  },
  kuidB: {
    content: {
      profileIds: ['profileA'],
      name: 'bar'
    },
    credentials: {
      local: { username: 'foo', password: 'barfoo' }
    }
  },
})

Users definition and especially their credentials are sensitive data that should not be hardcoded directly in the app.