Constructor
# new module:LoggedUser(userObj)
Parameters:
| Name | Type | Description |
|---|---|---|
userObj |
LoggedUser~JWTObject
|
Example
const user = new LoggedUser({ ... });
Methods
# async hasAllPermissions(permissions) → {Promise.<boolean>}
Returns true if the user has all the given permission(s).
Parameters:
| Name | Type | Description |
|---|---|---|
permissions |
Array.<string>
|
string
|
Promise.<boolean>
Example
const user = new LoggedUser({ ... });
console.log(user.hasAllPermissions([ "SYNC_DATA", "READ_STUDENTS" ])); // -> false
console.log(user.hasAllPermissions([ "READ_STUDENTS", "READ_OLD_STUDENTS" ])); // -> true
# async hasPermissions(permissions) → {Promise.<Object.<boolean>>}
Check if the user has the given permission(s). Return an object with true/false for each permission.
Parameters:
| Name | Type | Description |
|---|---|---|
permissions |
Array.<string>
|
string
|
Promise.<Object.<boolean>>
Example
const user = new LoggedUser({ ... });
console.log(user.hasPermissions([ "SYNC_DATA", "READ_STUDENTS" ])); // ->
// {
// "SYNC_DATA": false,
// "READ_STUDENTS": true
// }