Availability
This routine is available starting with katl-commons 1.0.
Syntax
userInGroup(group, user)
Description
Verifies if the selected user is in the selected group(s).Parameters
Parameter name | Type | Required | Description |
---|---|---|---|
group | string / string[] | Yes | The name(s) of the group(s) in which the user must be |
user | string | Yes | The name or key of the user that needs to be verified |
Return type
boolean (true/false)
A true return value means that the user associated with the specified username or userkey belongs to the given group(s).
Example
Example 1
userInGroup("Administrators", "Admin1");
Returns: True if Admin1 is included in "Administrators" group or False if Admin1 is not included in Administrators group.
Example 2
userInGroup("Users", currentUser());
Returns: True if the current user is included in "Users" group or False if the current user is not included in "Users" group.
Example 3
string[] groups = {"Administrators", "Users"}; userInGroup(groups, currentUser());
Returns: True if the current user is included in "Users" or "Administrators" group, or False if the current user is not included neither in "Users" nor in "Administrators" group.
Notes
The look-up is first made after the userkey, then after the username.
See also