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 DisplayResultmethods 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
password1TextBoxNodeId NodeId
The
password2TextBoxNodeId NodeId
The
selectedGroupNodeId NodeId
The
If null or invalid, the user is created without group associations.
displayLabelNodeId NodeId
The
Messages are displayed temporarily using DisplayResult.
<param name="SessionUserNodeId">NodeId of the
SessionUserNodeId NodeId
session Session
The active
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:
-
Resolve all UI components and the selected
using
ResolveNode<T>. -
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
.
-
Create a new
object using
InformationModel.MakeObject<T>(string)and add it to the user folder. -
Assign the initial password using
.
If password assignment fails, the newly created user node is removed. -
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. -
Display the appropriate localized result message and clear all input fields on success.
-
Execute the entire workflow inside
SafeExecuteto 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
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
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
group Group
The
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
Password assignment is performed via
If password assignment fails, the user node is removed and an
Examples
Programmatically creating a user with a group assignment:
Group operatorGroup = Project.Current.Get<Group>("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:
- Validate that the username is non-empty and does not already exist.
- Validate that the passwords are non-empty and match each other.
- Create a new
node and add it to the . - Set the initial password using the provided
session. If password assignment fails, remove the created user and throw an. - If a
groupis provided, resolve all subgroups and assign the new user to each group viaHasGroupreferences.
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
This value must match the User.BrowseName of the active user.
currentPassowordTextBoxNodeId NodeId
The
newNameTextBoxNodeId NodeId
The
disaplayLabelNodeId NodeId
The
Messages are displayed temporarily using DisplayResult.
SessionUserNodeId NodeId
The
Typically, this is the currently logged-in user.
session Session
The
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:
Resolving all
and nodes from their supplied values using ResolveNode<T>.Retrieving the current username, current password, and desired new username from the UI.
Validating that the username entered in the "current name" textbox matches the actual
User.BrowseNameof the active user.
If not, a localized mismatch error is displayed.Authenticating the user by calling
using the current username and password.
Authentication must succeed before the username can be changed.Applying the new username by assigning to
User.BrowseName.Displaying localized success or error messages using the provided label.
Clearing all input fields after a successful rename to prevent sensitive information from remaining visible.
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
password1TextBoxNodeId NodeId
The
password2TextBoxNodeId NodeId
The
displayLabelNodeId NodeId
The
Messages are automatically hidden after a short delay using
DisplayResult.
SessionUserNodeId NodeId
The
This is typically the currently logged-in user.
session Session
The current
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:
Resolves all UI and user references from the supplied
values using ResolveNode<T>.Retrieves the old password, the proposed new password, and the confirmation password from the UI fields.
Validates that the two new password entries match.
If they do not match, a localized validation error is shown to the operator.Attempts to update the password using
. Displays the result of the operation (success or failure) via the assigned
. If the password is changed successfully, all password input fields are cleared to prevent sensitive information from remaining visible.
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
displayLabelNodeId NodeId
The
Exceptions or validation failures are surfaced using DisplayResult through
SafeExecute.
SessionUserNodeId NodeId
NodeId of the
session Session
The current
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:
Resolves the user node from the provided
using ResolveNode<T>.
If the node cannot be resolved, the error is captured and displayed viaSafeExecute.Removes the user node from the system's primary user folder,
accessed through. Wraps the entire workflow in
SafeExecuteto 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
passwordTextBoxNodeId NodeId
The
displayLabelNodeId NodeId
The
The message is automatically hidden after a timeout via
DisplayResult.
panelLoaderNodeId NodeId
The
session Session
The current
Examples
UserManagementActions.Login(
UserNameTextBox.NodeId,
PasswordTextBox.NodeId,
MessageLabel.NodeId,
MainPanelLoader.NodeId,
Session);
Remarks
This method performs the following sequence:
Each
is resolved into its corresponding UI element using ResolveNode<T>, ensuring strong typing and early validation.The username and password values are retrieved from the UI.
The method invokes
to authenticate the user. If authentication succeeds, the
navigates to the user dashboard defined by UserManagementUtilities.UserScreen.If authentication fails, an appropriate localized error message is shown in the display label using
DisplayResult.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
password1TextBoxNodeId NodeId
The
password2TextBoxNodeId NodeId
The
displayLabelNodeId NodeId
The
Messages are displayed temporarily using DisplayResult.
SessionUserNodeId NodeId
NodeId of the
session Session
The active 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:
Resolves the
node and the password nodes from their provided values. 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.Attempts to reset the user's password by calling
.
The result is displayed in the provided label using theResultDictionaries.If the password reset succeeds, the input fields are cleared to prevent sensitive information from remaining visible.
The entire workflow is wrapped in
SafeExecuteto ensure that any exceptions are logged and displayed in the label without disrupting UI flow.