(key: string): any
(all: boolean): any
(arguments: {
all?: boolean,
key?: string,
default?: any,
}): any
The _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
: Ifall
is set totrue
, the entireuser
object is returned. One ofall
orkey
are required.key: string
: The value of the key in theuser
object 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 ofall
orkey
are required.default: any
: A value to return if thekey
is not found inuser
. By default,null
is returned if a value is not found.
Examples
Get the value of name
from user
:
_user: name
_user:
key: name
Returns: The value of name
in user
.
Get the entire user
object:
_user: true
_user:
all: true
Returns: 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.subfield
Returns: "Value"
.
Return a default value if the value is not found:
_user:
key: might_not_exist
default: Default value
Returns: 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: 2
then:
_user: my_array.$.value
Returns: 0
when used from the first block (0th index) in a list.