(key: string): any
(all: boolean): any
(arguments: {
all?: boolean,
key?: string,
default?: any,
}): anyThe _user operator gets a value from the user object. The user object contains the data in the user idToken if OpenID Connect authentication is configured and a user is logged in.
Arguments
string
If the _user operator is called with a string argument, the value of the key in the user object is returned. If the value is not found, null is returned. Dot notation and block list indexes are supported.
boolean
If the _user operator is called with boolean argument true, the entire user object is returned.
object
all: boolean: Ifallis set totrue, the entireuserobject is returned. One ofallorkeyare required.key: string: The value of the key in theuserobject is returned. If the value is not found,null, or the specified default value is returned. Dot notation and block list indexes are supported. One ofallorkeyare required.default: any: A value to return if thekeyis not found inuser. By default,nullis returned if a value is not found.
Examples
Get the value of name from user:
_user: name_user:
key: nameReturns: The value of name in user.
Get the entire user object:
_user: true_user:
all: trueReturns: The entire user object.
Dot notation:
Assuming user:
sub: abc123
name: User Name
my_object:
subfield: 'Value'then:
_user: my_object.subfield_user:
key: my_object.subfieldReturns: "Value".
Return a default value if the value is not found:
_user:
key: might_not_exist
default: Default valueReturns: The value of might_not_exist, or "Default value".
Block list indices:
Assuming user:
sub: abc123
name: User Name
my_array:
- value: 0
- value: 1
- value: 2then:
_user: my_array.$.valueReturns: 0 when used from the first block (0th index) in a list.
