User of session
Value resolver – Abstract
Purpose: Returns the 'user data' (user account/guest user account) for the applicable login context.
The User of session value resolver returns the 'user data' (the account) for the applicable login context.
The following scenarios can be determined at runtime:
Runtime scenario |
Return value of 'User of session' |
A full user (see Users) is logged in for the current session or has been specified via Login API for authentication and is considered a 'user' in the applicable login context. |
User account data (type: user) that authenticates the session or access via Login API. |
A guest user (see Guest users) is logged in for the current session or has been specified via Login API for authentication and is considered a 'user' in the applicable login context. |
Guest user account data (type: guest user) authenticating the session or access via Login API |
In the direct or indirect execution context of the value resolver, a Run as event action specifies a 'user' to temporarily define the applicable logon context different from the actual logged-on user or guest user. |
User account data (type: user) defined as 'user' in the temporary login context. |
►WARNING◄ Do not use return value for write accesses!
The return value of the User of session value resolver provides only a 'clone' of the account from the applicable login context, which may no longer correspond to the server-side data state for the account in question. When a user or guest user logs in to a Lobster Data Platform / Orchestration session, this clone is created as a 'snapshot' of the data from the account being used. This ensures that its data does not have to be repeatedly retrieved from the server during the session. The clone of the account valid for the user's session is only recreated if the logged-in user saves changes to their own account themselves (e.g. also through functions such as Change locale, Change profile picture, etc.).
Saving changes made to the cloned return value of the User of session value resolver – e.g. via Save changes later – fails (with error message including rollback for the transaction) if the server-side data state was updated by accesses from other sessions after the clone was created. To minimize the risk of a conflict when writing, the data of the account in question is fetched from the server immediately before write access, if possible. For this purpose, the 'ID' (id) of the account identified as User of session can be passed to the Input object (type safe) value resolver (see the 'Write access' example below).
Since the value resolver optionally returns the data of a user account or a guest user account, the GUI for the configuration defines the 'Interface > User' type for the return value of the value resolver. An Object property value resolver offers only the following very minimal selection of fields for this interface type, which are absolutely required for authentication with one or the other account types:
Field name |
Localization |
Data type |
Meaning |
Details |
id |
ID |
Long |
Absolute value identifies the 'user' account. |
For Users, the ID value is specified as a positive Long value. |
created |
Created |
Timestamp |
Account creation date. |
|
creatorId |
Creator |
Long |
Absolute value identifies the 'user' account that created the returned account. |
For Users, the ID value is specified as a positive Long value. |
ownerId |
Owner |
Long |
ID of the company account that owns the 'user' account. |
The value -1 signals that no owner is assigned. |
However, regardless of the definition of the 'Interface > User' type, the return value always includes all the data of the account that is considered the User of session.
►IMPORTANT◄ If a guest user is a User of session, the 'Interface > User' returns the value of the loginToken field for a client-side read access to the username field. Details on this special feature are illustrated in the example 'More complex use case' below.
►NOTE◄ When the User of session value resolver is used in a configuration, the logic implemented should be such that any of the scenarios listed at the beginning of this section can occur. However, the possibility that deployment conditions may change in the future should be considered, even if Guest users do not play a role on a Lobster Data Platform / Orchestration system to date, or no Run as event action is used in the immediate context. For example, a configuration in which only Users are expected as User of session should take suitable precautions to ensure that 'nothing can happen' in a guest user session. However, no essential workflow step should fail with a rollback or – possibly even worse – be executed with incomplete or inappropriate data just because the User of session is of the wrong type (Guest users vs. Users) or because a Run as event action within a complex call chain has brought an 'unexpected' user account into play.
Configuration
The value resolver ignores the input value and does not use any parameters.
Examples
Example: Restriction for a custom overview
Access to most entity types is controlled by Lobster Data Platform / Orchestration 'ownership' (ownerId) or Company authorizations, so the Company of session is usually the deciding factor for which Custom overviews entities will list in their data grid. It could be said that Lobster Data Platform / Orchestration does not provide 'private ownership' of entities, because systematically only Company accounts are provided for as owners or recipients of permissions. However, automatically populated default fields 'Creator' (creatorId) and 'Last modified by ID' (lastModifierId) of an entity refer to Users and Guest users, respectively. In the following example, a 'custom overview' for users is given an additional restriction on this basis, so that only those users for which the logged-in User of session is considered to be the 'creator' are displayed.
Configuration:
A 'custom overview' for Users is newly created and provided with the configuration for the Restriction shown on the right:
►NOTE◄ The interface returns the positive value of the guest user account ID as a negative value. However, the same logic applies to the value for 'Creator'. In this respect, the custom overview with this Restriction also works without special precautions for logging in as a guest user. ►NOTE◄ The ability of a guest user to create accounts for Users should normally be precluded by assigning a suitably restricted role to them. However, the Restriction in this form can be used for any entities. |
|
Runtime example:
The custom overview 'Users created by ►ME◄' lists only the two user accounts for 'Triple Q' created by the user themselves.
In accordance with the Restriction for the overview (see above), the Creator column shows the user name (username) and the ID of 'Triple Q' in all rows, if this is the User of session.
Example: Write access to the account identified as User of session
To minimize the risk of improper access to data in Lobster Data Platform / Orchestration, Guest users should be able to deactivate their own account by clicking on a ribbon button.
Runtime example:
Configuration:
The ribbon button (see above) triggers a Custom action event 'Deactivate my account', which is listed as a Triggering event for the event handling shown on the right. The Validating rule here explicitly ensures that the event actions shown below are only executed if a guest user is specified as the User of session. No input value is expected for the event, since the ribbon button is supposed to be offered in different contexts and not bound to the selection of a specific reference object. In this respect, a direct Check type on the 'guest user' type for the input value would be meaningless. Instead, the Check type here is executed inside a With rule for which the User of session value resolver in the Entity property resolver parameter temporarily changes the reference object. Even if its return value is the 'Interface > User' type (see image), a 'Guest user' object is present at runtime if Guest users are logged in. ►NOTE◄ The check type in the With rule is not assumed to be the context for the Action on passed rule, unlike a direct Check type for the input value of an event handler. Instead, the context here is considered undefined ('Object'). |
|
As an Action on passed rule, a logon context with appropriate access rights (see Role override) must first be established by a Run as event action, since it is assumed that a guest user is not authorized to change guest user accounts.
|
|
►IMPORTANT◄ The concatenation in the Object Resolver of the Execute with event action could be shortened considerably by using only the first and last 'stages'.
User of session > Input object (type safe) with 'Guest user' type
However, it is important not to proceed in this way, because otherwise the event actions will be executed with the 'cloned' account data at the time of the guest user login, which, in conjunction with Save changes later, can lead to a rollback error if the account has been modified since then starting from another session. This causes the clone to be considered 'outdated' by the server (see the 'Warning' in the introduction).
Example: More complex use case
It is possible to send an 'info note' (via e-mail) to other users/guest users in selected contexts via a ribbon macro, which refers to the current selection.
By clicking on the respective button, the logged-in user is able to select one of the following addressees for the notice via a context menu:
its own account (User of session)
the account with which the User of session was created (creatorId)
the account with which the User of session was last modified (lastModifierId)
The selection list should not include any account more than once, even if it is relevant in different functions.
The solution must be structured so that the accounts involved can be either Users or Guest users.
Runtime example:
The screenshot shows the ribbon button 'Info' which opened the displayed context menu.
The context menu shows two addressees for an info note to choose from.
Configuration:
The following describes only the configuration that concerns the opening of the context menu. The triggered notification expects the complete data object for the selected user or guest user account from the context menu in a variable.
The dynamic construction of the context menu is based on the data of the User of session (see parameter Object Resolver in the Execute with event action) in the stages shown on the right, which are described in detail below:
|
|
For the first step, a Set value event action is configured as shown on the right to assign the list of relevant account references to the accountIds variable (left side of the assignment). On the right side of the assignment, the list is defined by a concatenation of the following value resolvers:
At runtime, based on this configuration, the variable accountIds contains a list with at least one and at most three different Long values, each pointing to a user or guest user account. Positive Long values refer to Users and negative values to Guest users. |
|
For the second step, a suitable logon context is first established within a suitably parameterized Run as event action, so that there is sufficient access to the accounts that are read. In the example (not shown in the image), the 'Super user' role is claimed. This gives full access to all accounts regardless of the selection of a specific 'company'. The call-off of the accounts for the context menu via a Search (Event action) must be done in two steps, because only one specific entity type (Users or Guest users) can be called from the server at a time. The image on the right shows the configuration for the Search (Event action) for the Users Entity:
At runtime, after executing the Search (Event action), the users variable contains a list of entities of the Users type, which can also be empty if the accountIds variable contains only negative values referring to Guest users. ►NOTE◄ The Search (Event action) only 'finds' Users that can be read in the applicable login context. This depends here on the parameters of the surrounding Run as event action. Selecting this option incorrectly may result in relevant Users being 'missing' as addressees in the context menu. |
|
A second Search (Event action), concerning the Guest users Entity, again defines the 'Search value' Mode and a Search of the 'Search' type. The result is a list of Guest users accounts to be written to the guests (not shown in the image) variable. For this Search (Event action), Where uses the configuration shown on the right. This is done in a similar way to Where for the Users (see above) with the following important differences.
At runtime, after the Search (Event action) is executed, the guests variable contains a list of entities of Guest users type, which can also be empty if the accountIds variable contains only positive values referring to Users. ►NOTE◄ The Search (Event action) only 'finds' Guest users that can be read in the applicable login context. This depends here on the parameters of the surrounding Run as event action. When this is selected inappropriately, relevant Guest users may be 'missing' as addressees in the context menu. |
|
The third step is to merge the accounts collected in the users and guests variables and return a unified list for Users and Guest users. Since this list of accounts should directly define the selection options for the context menu to be opened, this formatting can be placed directly in the Show context menu event action:
|
|
On the basis of the previous configuration, the Users always appear above the Guest users in the context menu and in the order in which they are returned by the associated Search (Event action).
Although the order is not of great importance with a maximum of three entries, its effect will be demonstrated here:
A Sort list value resolver is attached to the existing concatenation for the Root items parameter within the Show context menu event action, defining the username field as a Compare value.
Runtime example:
However, appearances are deceptive, as another sample in the context of another guest user proves:
|
|
As seen in the last 'runtime example' (above), sorting between multiple guest user entries in the context menu does not take effect with the previous configuration. The entry beginning with the digit '6' should otherwise appear at position 2. The background:
In order to neutralize this problem, the configuration can be adjusted. (e.g. as shown on the right):
|
|
►NOTE◄ If the context menu is not created via event handling but via Client workflow, the fallback rule for the username also applies to the Sort list, so that the most recently added Concat strings can be omitted. However, the Run as event action is not available in a Client workflow, so sufficient read permissions must be ensured in the logon context applicable to the Client workflow to search for the accounts (in the second step).