Develop a NetLogic that handles logins

This NetLogic validates usernames and passwords.
Set the default external code editor. See Set the default code editor.
  1. In
    Project view
    , double-click
    The external code editor opens.
  2. In the code editor, replace the existing code with the following code:
    #region Using directives using System; using UAManagedCore; using OpcUa = UAManagedCore.OpcUa; using FTOptix.HMIProject; using FTOptix.UI; using FTOptix.NativeUI; using FTOptix.Core; using FTOptix.CoreBase; using FTOptix.NetLogic; #endregion public class LoginFormNetLogic : BaseNetLogic { public override void Start() { // Insert code to be executed when the user-defined logic is started } public override void Stop() { // Insert code to be executed when the user-defined logic is stopped } [ExportMethod] public void Login(string username, string password) { if (!PerformLogin(username, password)) { // Set incorrect login message var messageVariable = LogicObject.GetVariable("Message"); messageVariable.Value = "Incorrect login"; return; } // Check the correct type of PanelLoader PanelLoader panelLoader = (PanelLoader)Owner.Owner; if (panelLoader == null) { Log.Error(panelLoader + " is not a PanelLoader"); return; } // Retrieve Panel variable var panelVariable = (NodeId)LogicObject.GetVariable("Panel").Value; if (panelVariable == NodeId.Empty) { Log.Error("Panel variable is empty"); return; } // Perform ChangePanel panelLoader.ChangePanel(panelVariable, NodeId.Empty); } private bool PerformLogin(string username, string password) { return Session.ChangeUser(username, password); } }
  3. Save the code.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.