Passa al contenuto principale

Class UserManagementActions

Namespace: TecnoPack.UsersManager
Assembly: CO0002_Templ_FlowpackHMI_V00_26_M.dll

Provides high-level user-management actions that orchestrate UI interaction, authentication logic, and navigation between screens in the HMI.

public static class UserManagementActions

Inheritance

object ← UserManagementActions

Remarks

This partial class contains action-oriented helper methods used across the user management subsystem. These actions typically combine:

  • Resolution of UI components from values using ResolveNode<T> extension methods.

  • Execution of user-related operations through the underlying object (e.g., login).

  • Consistent UI feedback via elements, typically using DisplayResult methods for timed message visibility.

  • Optional screen navigation using instances.

The structure promotes separation of concerns by keeping UI resolution, timed feedback, and safe exception handling in separate extension helpers, while this class focuses only on the business-level action flows.

Methods

AddUser(NodeId, NodeId, NodeId, NodeId, NodeId, NodeId, Session)

Creates a new user in the FT Optix security model, validates the provided username and password fields, assigns the user to the selected group hierarchy, and provides visual feedback through a UI label.

public static void AddUser(NodeId userNameTextBoxNodeId, NodeId password1TextBoxNodeId, NodeId password2TextBoxNodeId, NodeId selectedGroupNodeId, NodeId displayLabelNodeId, NodeId SessionUserNodeId, Session session)

Parameters

userNameTextBoxNodeId NodeId

The referencing the containing the proposed username for the new user.

password1TextBoxNodeId NodeId

The referencing the first used to enter the initial password for the new user.

password2TextBoxNodeId NodeId

The referencing the second used to confirm the password. Both password fields must match.

selectedGroupNodeId NodeId

The referencing the group selected in the UI to assign the new user to.
If null or invalid, the user is created without group associations.

displayLabelNodeId NodeId

The referencing the used to display success messages, validation messages, or error feedback.
Messages are displayed temporarily using DisplayResult. <param name="SessionUserNodeId">NodeId of the currently logged in.</param>

SessionUserNodeId NodeId

session Session

The active used to set the initial user password.

Examples

Example usage inside a NetLogic event handler:

UserManagementActions.AddUser(
NewUserNameBox.NodeId,
NewUserPasswordBox1.NodeId,
NewUserPasswordBox2.NodeId,
SelectedGroupCombo.NodeId,
MessageLabel.NodeId,
Session);

Remarks

This method performs a complete user creation workflow and enforces several business and security rules to maintain structural integrity in the user model.

The workflow consists of the following steps:

  1. Resolve all UI components and the selected

    using ResolveNode<T>.

  2. Read the username and password fields and validate:

    • Username cannot be empty.
    • Passwords cannot be empty.
    • Password fields must match.
    • Username must not already exist in .
  3. Create a new

    object using InformationModel.MakeObject<T>(string) and add it to the user folder.

  4. Assign the initial password using .
    If password assignment fails, the newly created user node is removed.

  5. If a group is selected, retrieve all known groups and assign the user to the selected group and all its subgroups using hierarchical resolution via Groups.GetSubGroups.

  6. Display the appropriate localized result message and clear all input fields on success.

  7. Execute the entire workflow inside SafeExecute to ensure consistent error handling and UI feedback.

AddUser(string, string, string, Group, Session)

Creates a new user programmatically without relying on UI nodes.
This overload validates the provided username and password, creates a new object, sets its initial password using the specified , and optionally assigns the user to a specified group and all its subgroups.

public static void AddUser(string username, string password1, string password2, Group group, Session session)

Parameters

username string

The proposed username for the new user. Must be non-empty and unique within the .
An is thrown if the username is invalid or already exists.

password1 string

The initial password for the new user. Must be non-empty and match password2.

password2 string

The confirmation password. Must match password1.
If the passwords do not match, an is thrown.

group Group

The to assign the new user to.
If null, the user is created without any group associations.
If a group is provided, the user is automatically added to the specified group and all its subgroups resolved via .

session Session

The active used to set the initial password for the new user.
Password assignment is performed via .
If password assignment fails, the user node is removed and an is thrown.

Examples

Programmatically creating a user with a group assignment:

Group operatorGroup = Project.Current.Get&lt;Group&gt;("Operators");
Session session = Project.Current.Session;
UserManagementActions.AddUser("jdoe", "password123", "password123", operatorGroup, session);

Remarks

This overload is intended for programmatic scenarios where UI elements are not involved. It performs the following steps:

  1. Validate that the username is non-empty and does not already exist.
  2. Validate that the passwords are non-empty and match each other.
  3. Create a new node and add it to the .
  4. Set the initial password using the provided session. If password assignment fails, remove the created user and throw an .
  5. If a group is provided, resolve all subgroups and assign the new user to each group via HasGroup references.

Unlike the UI-based overload, this method throws exceptions directly for invalid inputs or failed operations instead of providing visual feedback via labels.

ChangeName(NodeId, NodeId, NodeId, NodeId, NodeId, Session)

Attempts to change the username of the currently authenticated user, validating the current username, verifying the password, and providing visual feedback to the operator through a UI label.

public static void ChangeName(NodeId currentNameTextBoxNodeId, NodeId currentPassowordTextBoxNodeId, NodeId newNameTextBoxNodeId, NodeId disaplayLabelNodeId, NodeId SessionUserNodeId, Session session)

Parameters

currentNameTextBoxNodeId NodeId

The referencing the containing the user's current username.
This value must match the User.BrowseName of the active user.

currentPassowordTextBoxNodeId NodeId

The referencing the where the user enters their current password, used for authentication prior to renaming.

newNameTextBoxNodeId NodeId

The referencing the containing the new username that the user wishes to apply.

disaplayLabelNodeId NodeId

The referencing the used to display validation messages, authentication errors, or success feedback.
Messages are displayed temporarily using DisplayResult.

SessionUserNodeId NodeId

The referencing the whose username is being changed.
Typically, this is the currently logged-in user.

session Session

The used to authenticate the user via before applying the username change.

Examples

Example usage inside a NetLogic event handler:

UserManagementActions.ChangeName(
CurrentNameBox.NodeId,
CurrentPasswordBox.NodeId,
NewNameBox.NodeId,
MessageLabel.NodeId,
SessionUserNode.NodeId,
Session);

Remarks

This method performs a complete username-change workflow for the HMI environment. The workflow includes:

  1. Resolving all and nodes from their supplied values using ResolveNode<T>.

  2. Retrieving the current username, current password, and desired new username from the UI.

  3. Validating that the username entered in the "current name" textbox matches the actual User.BrowseName of the active user.
    If not, a localized mismatch error is displayed.

  4. Authenticating the user by calling using the current username and password.
    Authentication must succeed before the username can be changed.

  5. Applying the new username by assigning to User.BrowseName.

  6. Displaying localized success or error messages using the provided label.

  7. Clearing all input fields after a successful rename to prevent sensitive information from remaining visible.

  8. Running the entire workflow inside SafeExecute, ensuring that exceptions are consistently logged and presented to the operator without disrupting UI flow.

ChangePassword(NodeId, NodeId, NodeId, NodeId, NodeId, Session)

Attempts to change the password of the currently authenticated user, validates the new password fields entered in the HMI, and displays visual feedback regarding the result of the operation.

public static void ChangePassword(NodeId oldPasswordTextBoxNodeId, NodeId password1TextBoxNodeId, NodeId password2TextBoxNodeId, NodeId displayLabelNodeId, NodeId SessionUserNodeId, Session session)

Parameters

oldPasswordTextBoxNodeId NodeId

The referencing the containing the user's current (old) password.

password1TextBoxNodeId NodeId

The of the first used to enter the new password.

password2TextBoxNodeId NodeId

The of the second used to confirm the new password. Both fields must contain identical values.

displayLabelNodeId NodeId

The referencing the used to display validation or error messages.
Messages are automatically hidden after a short delay using DisplayResult.

SessionUserNodeId NodeId

The referencing the whose password is being changed.
This is typically the currently logged-in user.

session Session

The current through which the password change operation is performed using .

Examples

Example usage inside a NetLogic method:

UserManagementActions.ChangePassword(
OldPasswordBox.NodeId,
NewPasswordBox1.NodeId,
NewPasswordBox2.NodeId,
MessageLabel.NodeId,
SessionUserNode.NodeId,
Session);

Remarks

This method performs the following sequence:

  1. Resolves all UI and user references from the supplied values using ResolveNode<T>.

  2. Retrieves the old password, the proposed new password, and the confirmation password from the UI fields.

  3. Validates that the two new password entries match.
    If they do not match, a localized validation error is shown to the operator.

  4. Attempts to update the password using .

  5. Displays the result of the operation (success or failure) via the assigned .

  6. If the password is changed successfully, all password input fields are cleared to prevent sensitive information from remaining visible.

  7. The entire process is executed inside SafeExecute, ensuring that any unexpected exceptions are logged and shown to the operator in a consistent user-friendly manner.

DeleteUser(NodeId, NodeId, NodeId, Session)

Deletes an existing user from the FT Optix security model and provides consistent error handling and UI feedback through a display label.

public static void DeleteUser(NodeId userNodeId, NodeId displayLabelNodeId, NodeId SessionUserNodeId, Session session)

Parameters

userNodeId NodeId

The referencing the instance to be deleted. This must reference a valid user node located within the project's security hierarchy.

displayLabelNodeId NodeId

The referencing the used to display any errors that occur during the deletion process.
Exceptions or validation failures are surfaced using DisplayResult through SafeExecute.

SessionUserNodeId NodeId

NodeId of the currently logged in.

session Session

The current used to validate permissions for the delete operation.
This is passed to Groups.ValidateOperation to ensure the caller has sufficient rights before the user is removed.

Examples

Example usage inside a NetLogic event handler:

UserManagementActions.DeleteUser(
SelectedUserNode.NodeId,
MessageLabel.NodeId,
session);

Remarks

This method performs a minimal but essential workflow:

  1. Resolves the user node from the provided using ResolveNode<T>.
    If the node cannot be resolved, the error is captured and displayed via SafeExecute.

  2. Removes the user node from the system's primary user folder,
    accessed through .

  3. Wraps the entire workflow in SafeExecute to ensure that exceptions are logged and reported in a user-friendly manner.

No success message is shown by default; if desired, this behavior can be added by displaying a localized result through the supplied label.

Login(NodeId, NodeId, NodeId, NodeId, Session)

Attempts to authenticate a user based on the username and password entered in the referenced UI fields, provides visual feedback regarding the result, and conditionally navigates to the user management screen upon success.

public static void Login(NodeId userNameTextBoxNodeId, NodeId passwordTextBoxNodeId, NodeId displayLabelNodeId, NodeId panelLoaderNodeId, Session session)

Parameters

userNameTextBoxNodeId NodeId

The referencing the containing the username entered by the operator.

passwordTextBoxNodeId NodeId

The referencing the containing the password entered by the operator.

displayLabelNodeId NodeId

The of the used to display error messages when authentication fails.
The message is automatically hidden after a timeout via DisplayResult.

panelLoaderNodeId NodeId

The of the used to navigate to the main user-management interface when authentication succeeds.

session Session

The current used to perform authentication through .

Examples

UserManagementActions.Login(
UserNameTextBox.NodeId,
PasswordTextBox.NodeId,
MessageLabel.NodeId,
MainPanelLoader.NodeId,
Session);

Remarks

This method performs the following sequence:

  1. Each is resolved into its corresponding UI element using ResolveNode<T>, ensuring strong typing and early validation.

  2. The username and password values are retrieved from the UI.

  3. The method invokes to authenticate the user.

  4. If authentication succeeds, the navigates to the user dashboard defined by UserManagementUtilities.UserScreen.

  5. If authentication fails, an appropriate localized error message is shown in the display label using DisplayResult.

  6. All exceptions are captured and translated into user-visible messages by wrapping the entire workflow in SafeExecute, ensuring that failures do not break UI logic.

This design ensures a clean separation of UI resolution, business logic, user feedback, and exception handling.

RecoverPassword(NodeId, NodeId, NodeId, NodeId, NodeId, Session)

Resets or recovers the password for a specified user by updating it directly in the session, validating input fields, and providing UI feedback through a label.

public static void RecoverPassword(NodeId userNodeId, NodeId password1TextBoxNodeId, NodeId password2TextBoxNodeId, NodeId displayLabelNodeId, NodeId SessionUserNodeId, Session session)

Parameters

userNodeId NodeId

The referencing the whose password will be reset.

password1TextBoxNodeId NodeId

The referencing the where the new password is entered.

password2TextBoxNodeId NodeId

The referencing the where the new password is confirmed. Both fields must match.

displayLabelNodeId NodeId

The referencing the used to display validation messages, error messages, or success feedback.
Messages are displayed temporarily using DisplayResult.

SessionUserNodeId NodeId

NodeId of the currently logged in.

session Session

The active used to update the user's password through ChangePasswordInternal.

Examples

Example usage inside a NetLogic event handler:

UserManagementActions.RecoverPassword(
TargetUserNode.NodeId,
NewPasswordBox1.NodeId,
NewPasswordBox2.NodeId,
MessageLabel.NodeId,
Session);

Remarks

This method performs the following workflow:

  1. Resolves the node and the password nodes from their provided values.

  2. Reads the new password and confirmation fields and validates that they are non-empty and match.
    If validation fails, an appropriate localized message is displayed.

  3. Attempts to reset the user's password by calling .
    The result is displayed in the provided label using the ResultDictionaries.

  4. If the password reset succeeds, the input fields are cleared to prevent sensitive information from remaining visible.

  5. The entire workflow is wrapped in SafeExecute to ensure that any exceptions are logged and displayed in the label without disrupting UI flow.

  • Remarks
  • Methods
    • AddUser(NodeId, NodeId, NodeId, NodeId, NodeId, NodeId, Session)
    • AddUser(string, string, string, Group, Session)
    • ChangeName(NodeId, NodeId, NodeId, NodeId, NodeId, Session)
    • ChangePassword(NodeId, NodeId, NodeId, NodeId, NodeId, Session)
    • DeleteUser(NodeId, NodeId, NodeId, Session)
    • Login(NodeId, NodeId, NodeId, NodeId, Session)
    • RecoverPassword(NodeId, NodeId, NodeId, NodeId, NodeId, Session)