Constructor
new CurrentUser(userData, userAuthorities, modelDefinitions, settings)
- Source:
Creates the CurrentUser.
Parameters:
Name | Type | Description |
---|---|---|
userData |
Object | Payload as returned from the api when requesting the currentUser object. |
userAuthorities |
UserAuthorities | The UserAuthorities object for the currentUsers authorities. |
modelDefinitions |
Array.<ModelDefinition> | The modelDefinitions that need to be used for checking access. |
settings |
UserSettings | The userSettings object to be set onto the current user object. |
Members
authorities :UserAuthorities
- Source:
Type:
- UserAuthorities
dataStore :UserDataStore
- Source:
Contains a reference to UserDataStore
Type:
- UserDataStore
userSettings :UserSettings
- Source:
d2.currentUser.userSettings.get('keyUiLocale')
.then(userSettingsValue => {
console.log('UI Locale: ' + userSettingsValue);
});
Type:
- UserSettings
Methods
(static) create(userData, authorities, modelDefinitions, userSettings) → {CurrentUser}
- Source:
Factory method for creating a CurrentUser instance
Parameters:
Name | Type | Description |
---|---|---|
userData |
Object | Payload as returned from the api when requesting the currentUser object. |
authorities |
Array.<string> | A list of authorities that the currentUser has. |
modelDefinitions |
Array.<ModelDefinition> | The modelDefinitions that need to be used for checking access. |
userSettings |
Object | Payload as returned from the api when request the userSettings |
Returns:
The created CurrentUser object based on the data given.
- Type
- CurrentUser
canCreate(modelDefinition) → {boolean}
- Source:
Check if the user has the authority to create objects of a type of Model (based on it's modelDefinition) If the object supports public and private objects then both are checked, and the method will return true if one of them is true. (e.g. will also return true if the user can only create private objects)
Parameters:
Name | Type | Description |
---|---|---|
modelDefinition |
ModelDefinition | The modelDefinition that the authorities should be checked for. |
Returns:
True when the user has the permission to create the object
- Type
- boolean
canCreatePrivate(modelDefinition) → {boolean}
- Source:
Check if the user has the authority to create private objects of a type of Model (based on it's modelDefinition)
Parameters:
Name | Type | Description |
---|---|---|
modelDefinition |
ModelDefinition | The modelDefinition that the authorities should be checked for. |
Returns:
True when the user has the permission to create the object
- Type
- boolean
canCreatePublic(modelDefinition) → {boolean}
- Source:
Check if the user has the authority to create public objects of a type of Model (based on it's modelDefinition)
Parameters:
Name | Type | Description |
---|---|---|
modelDefinition |
ModelDefinition | The modelDefinition that the authorities should be checked for. |
Returns:
True when the user has the permission to create the object
- Type
- boolean
canDelete(modelDefinition) → {boolean}
- Source:
- Deprecated:
- Delete should be checked through the `Model.access.delete` property instead, as that also takes into account sharing. Just checking if the user has the authority to delete a specific object does not take into account the full ACL.
Check if the user has the authority to delete objects of a type of Model (based on it's modelDefinition)
Parameters:
Name | Type | Description |
---|---|---|
modelDefinition |
ModelDefinition | The modelDefinition that the authorities should be checked for. |
Returns:
True when the user has the permission to delete the object
- Type
- boolean
canUpdate(modelDefinition) → {boolean}
- Source:
- Deprecated:
- Update should be checked through the `Model.access.update` property instead, as that also takes into account sharing. Just checking if the user has the authority to update a specific object does not take into account the full ACL.
Check if the user has the authority to update objects of a type of Model (based on it's modelDefinition)
Parameters:
Name | Type | Description |
---|---|---|
modelDefinition |
ModelDefinition | The modelDefinition that the authorities should be checked for. |
Returns:
True when the user has the permission to update the object
- Type
- boolean
getDataViewOrganisationUnits(listOptionsopt) → {Promise.<ModelCollection>}
- Source:
Requests a users data view organisation units from the api.
The users data view organisation units are lazy loaded on init of the library (just the ids). This method can be used to load the full representation of the dataViewOrganisationUnits.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
listOptions |
Object |
<optional> |
{}
|
Additional query parameters that should be send with the request. |
Returns:
A ModelCollection that contains the user's dataViewOrganisationUnits.
- Type
- Promise.<ModelCollection>
getOrganisationUnits(listOptionsopt) → {Promise.<ModelCollection>}
- Source:
Requests a users primary organisation units from the api.
The users organisation units are lazy loaded on init of the library (just the ids). This method can be used to load the full representation of the organisationUnits.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
listOptions |
Object |
<optional> |
{}
|
Additional query parameters that should be send with the request. |
Returns:
A ModelCollection that contains the user's organisationUnits.
- Type
- Promise.<ModelCollection>
getUserGroups() → {Promise.<ModelCollection>}
- Source:
Get a ModelCollection of userGroup models that are assigned to the currentUser
The user groups are lazy loaded on init of the library. This method can be used to load the full representation of the userGroups.
The request done is equivalent do doing https://play.dhis2.org/demo/api/27/me.json?fields=userGroups[:all]
Returns:
The model collection that contains the user's groups.
- Type
- Promise.<ModelCollection>
getUserRoles() → {Promise.<ModelCollection>}
- Source:
Get a ModelCollection of userRole models that are assigned to the currentUser
The user roles are lazy loaded on init of the library. This method can be used to load the full representation of the userGroups.
The request done is equivalent do doing https://play.dhis2.org/demo/api/27/me.json?fields=userCredentials[userRoles[:all]]
Returns:
A ModelCollection that contains the user's groups.
- Type
- Promise.<ModelCollection>