Force Logout When New User Logs In

2020-06-08
2020-06-15
  • jackcaissey - 2020-06-08

    Hello all,

    What I have been trying to do is create a program which checks to see if a new user has logged in, and if a new user has logged in, force logout existing users. I am trying to do this by checking to see if VisuNativeControl.CurrentFullUserName does not equal the logged in user on record. When this condition is met, the program will call VisuElems.Visu_FctLogoutUser(pClient) where pClient is a pointer to VisuElems.VisuElemBase.VisuStructClientData. This method does not seem to actually log out the existing user. Is there some other method which can be used to log out the user? Please let me know

     
  • m.prestel - 2020-06-09

    Hello @jackcaissey,

    you should be able to logout a user with this internal function.
    Could you provide a example project?

    Best regards,
    Marcel

     
  • jackcaissey - 2020-06-09
    VisuElems.g_ClientManager.BeginIteration();
    
    IF isLoggedIn THEN
            WHILE (pClient := VisuElems.VisuElemBase.g_ClientManager.GetNextClient()) <> 0 DO
                IF pClient^.GlobalData.CurrentUserName = loggedInUser THEN
                    EXIT;
                END_IF
            END_WHILE
            IF NOT (pClient = 0) THEN
                VisuElems.Visu_FctLogoutUser(pClient);
                loggedInUser := VisuNativeControl.CurrentFullUserName;      //record new logged in user
            END_IF
    ELSE                                                                    //else there's no logged in user on record
        LoggedInUser := VisuNativeControl.CurrentFullUserName;              //logged in user on record is set to the name newly entered
        isLoggedIn := TRUE;                                                 //logged in state is changed to true
    END_IF
    

    What this should do (or at least what I hope it should do) is iterate through the list of active users until it finds a user with a username which matches the recorded logged in user's username. Once this is found it should logout the user then record the new user's username. If no user is logged in then it skips this and simply logs in whichever user decides to log in.

     
  • marci4

    marci4 - 2020-06-15

    Hello @jackcaissey,

    attached you can find an example using the recommended way to look through all clients.

    Best regards,
    Marcel

     

Log in to post a comment.