This server-side class allows to get information about the current user and his prerequisites, for example, assigned roles and preferences.
This method allows to get user information given the context (whether this is the system user or an employee having additional attributes against regular users).
Return:
Type | Description |
---|---|
SimpleRecord object | This method returns an object containing user information. |
Example:
const user = new SimpleUser(); ss.info(user.getContext().username); //admin |
This method gets the current user' ID.
Return:
Type | Description |
---|---|
String | Current user ID. |
const record = new SimpleUser(); ss.info(record.getID()); |
This method allows to get a value of the specified User Preference for the current user.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
preferenceName | String | Y | N |
Return:
Type | Description |
---|---|
String | This method returns the specified preference value for the current user. If the specified preference does not exist, it returns 'null'. |
const record = new SimpleUser(); ss.info("Is the navigator menu pinned for this user? " + record.getPreference('menu.pin')); // -1 / 0 / 1 |
This method allows to find out whether the current user is granted with a specified role or not.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
role | String | Y | N |
Return:
Type | Description |
---|---|
Boolean | This method approves or disproves an assumption whether a specified user is granted with a specified role. |
const record = new SimpleUser(); ss.info("Does this user have the security admin role? " + record.hasRole('security_admin')); // true | false |
This method allow to set a value for an existing or newly created preference for the current user.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
preferenceName | String | Y | N |
value | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
const record = new SimpleUser(); record.setPreference('menu.pin', '1'); ss.info(record.getPreference('menu.pin')); // 1 |