Module: loopback

Class: Role object

Role

The Role model

Role.getRoles(context, callback)

List roles for a given principal.

Arguments
Name Type Description
context Object

The security context.

callback Function

Callback function.

Callback
Name Type Description
err Error

Error object.

roles Array.<String>

An array of role IDs

Role.isAuthenticated(context, callback)

Check if the user ID is authenticated

Arguments
Name Type Description
context Object

The security context.

callback Function

Callback function.

Callback
Name Type Description
err Error

Error object.

isAuthenticated Boolean

True if the user is authenticated.

Role.isInRole(role, context, callback)

Check if a given principal is in the specified role.

Arguments
Name Type Description
role String

The role name.

context Object

The context object.

callback Function

Callback function.

Callback
Name Type Description
err Error

Error object.

isInRole Boolean

True if the principal is in the specified role.

Role.isOwner(modelClass, modelId, userId, callback)

Check if a given user ID is the owner the model instance.

Arguments
Name Type Description
modelClass Function

The model class

modelId

The model ID

userId

The user ID

callback Function

Callback function

Role.registerResolver(role, resolver)

Add custom handler for roles.

Arguments
Name Type Description
role String

Name of role.

resolver Function

Function that determines if a principal is in the specified role. Should provide a callback or return a promise.