This server-side class allows to get information about the current user and his prerequisites, for example, assigned roles and preferences.
This method returns access token of the current user within the current session.
In some cases it returns an empty string. These cases are:
Return:
Type | Description |
---|---|
String | Method returns the current user access token. If it is not set, then an empty string is returned. |
Example:
<![CDATA[const user = new SimpleUser(); ss.info(user.getAccessToken()); // Info: PV8wLSJWEJONyvF87aIQn2b--7EMEhy_ |
This method allows to get current 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 the current user information. |
Example:
<![CDATA[const user = new SimpleUser(); ss.info(user.getContext().username); // Info: admin |
This method gets the current user ID.
Return:
Type | Description |
---|---|
String | Current user ID. |
<![CDATA[const user = new SimpleUser(); ss.info(user.getID()); // Info: 155931135900000099 |
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'. |
<![CDATA[const user = new SimpleUser(); ss.info(user.getPreference('application')); // Info: 155931135900000002 |
This method allows to find out whether the current user is granted with a specified role or not. It always returns true if the current user has the admin role.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
role | String | Y | N |
Return:
Type | Description |
---|---|
Boolean | This method returns 'true' if user is granted with a specified role; otherwise, it returns 'false'. |
<![CDATA[const user = new SimpleUser(); ss.info(user.hasRole('service_owner')); // Info: false |
Use this method to set a value for the User Preference settings of the current user.
The system creates a preference with the given name for the current user if such a preference did not exist before.
The value parameter must be no longer than 255 symbols. |
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. |
<![CDATA[const user = new SimpleUser(); user.setPreference('language', 'en'); ss.info(user.getPreference('language')); // Info: en |