Hi there,
is it possible to make my own custom login dialog instead of using the native ugly codesys one? If there is can you explain how?
Thanks!
Hi there,
is it possible to make my own custom login dialog instead of using the native ugly codesys one? If there is can you explain how?
Thanks!
Hello,
You can open the “Login” dialog in the library “VisuDialogs” using the Library Manager. Although it cannot be edited there, it can be copied.
Note: It is easier to copy and edit the existing dialog than to create a new one from scratch.
Personally, I am not a fan of dialogs and prefer a start page with two fields for username and password and a login button. This can be achieved using the function VisuUserManagement.g_VisuUserMgmt2.LoginToUserGroup(). Attached is an example for both approaches.
OwnLogInDialog_MKv3.1_CS3.5.21.5.project (539.1 KB)
Hi there. Just a small issue: My project, I assume by default, was using the library visuusermanagement.VUM_Login as the default Login Dialog. Which I cannot open it because it’s creator protected. And when I do it with Visu Dialog as you’re saying. When I go to Visualization Manager to select the Login Dialog to use, it does not accept any other than VUM_Dialog. And if I delete that library, the dropdown options from User management just go blurred. Any guess why?
Thank you!
Hello,
I also can no longer select other dialogs. This is likely since the introduction of runtime-based user management. Even the dialog from VisuDialogs is no longer available for selection. Unfortunately, the dialogs from VisuUserMgmt cannot be opened and copied.
However, what still works is opening your own dialog (Properties > Visualization > Option “Dialog must be active”) via Input Configuration > Open Dialog, instead of Input Configuration > User Management > Login. The example in the first post implements it this way as well.
// Validate client pointer
IF pClient = 0 THEN
FC_Login := 16#FFFF; // Client pointer invalid
RETURN;
END_IF
// 1. Initial Login attempt
uidReturn := VisuUserManagement.g_VisuUserMgmt2.Login(pClient, wsUserName, wsPassword);
// 2. Case sensitivity fallback for the first character (UTF-8 / ASCII)
IF uidReturn <> 0 THEN
CASE wsUserName[0] OF // UTF-8 Table
16#61..16#7A: // a..z -> A..Z
wsUserName[0] := wsUserName[0] - 32;
16#41..16#5A: // A..Z -> a..z
wsUserName[0] := wsUserName[0] + 32;
END_CASE
// Retry login with toggled first letter case
uidReturn := VisuUserManagement.g_VisuUserMgmt2.Login(pClient, wsUserName, wsPassword);
END_IF
// 3. Post-login routing or session reset
IF uidReturn = 0 THEN
// Switch visualization page if a target is defined
IF sTargetVisuName <> '' THEN
FC_SwitchVisu(pClient, sTargetVisuName);
END_IF
ELSE
// Force a clean logout on failure
VisuUserManagement.g_VisuUserMgmt2.Logout(pClient);
END_IF
FC_Login := uidReturn;
First of all, thank you very much for sharing this custom login dialog solution! It was extremely helpful for my project.
I wanted to share a small bug/behavior I encountered while running this on CODESYS V3.5 SP21 Patch 3.
Initially, the custom login would fail on the very first attempt after starting the WebVisu. It only worked after performing a login via the native CODESYS dialog first. This was happening because FB_VUMgt.CheckLoginIntern validates credentials against the internal DB, but doesn’t initialize the active client session state on cold starts.
To fix this, I modified FC_Login to use VisuUserManagement.g_VisuUserMgmt2.Login(pClient, wsUserName, wsPassword) directly instead of CheckLoginIntern followed by LoginToUserGroup. This forces the runtime to properly bind and initialize the user session on the first attempt without needing the native dialog.
I’m attaching the updated FC_Login code snippet in case you want to include this adjustment in your project template for newer CODESYS versions.
Once again, thanking you so much for the help!!
I had already forwarded the behavior for review and left a note in the code. Many thanks for researching and providing the solution!