Auto Log Out if User non active

Hi, I have a task

I have CMS for table Users. In CMS, you can make users not active.

if user not active in table Users, i want make auto log out in Mobile


How can i do that?


Thanks

Hello Christopher, 

If I have understood correctly, you are maintaining your users in your own Users table and you can make a User inactive from your CMS.  The below is relevant only if my understanding is correct. 

When you make an User inactive, you want the user on the mobile to log out automatically. 

You need to create an action that checks if the user is active or not and logs the user out and you need to call this action at various check points in your app (like screen actions).

This is a lot of effort, which can be avoided if you are using OutSystems users.  


Regards 


Hi Amal,

Thanks for your reply

That correct scenario..

I will consider it


Regards

Hello Christopher, 

As you are using external login, do check the below post that has quite a lot of information which might help you 

https://www.outsystems.com/forums/discussion/44688/questions-regarding-external-login/


Best Regards

Hi Christopher,

Logging out an inactive user, can only be done if the Mobile application is aware that the User became inactive. In order to achieve this it will have to communicate with the server (and has to be online for this to work).

If this is unavoidable, my suggestion is:

  1. Create a AutoLogoutOnInactive Server Action that:
    1. If the user returned by GetUser(GetUserId()) has its Is_Active property set to False:
      1. Calls Users_Logout();
      2. Raises a Security Exception
  2. Create a CheckInactiveUser Client Action that:
    1. If the device is online calls the AutoLogoutOnInactive Server Action.
  3. Create a InactiveUserChecker Block (or implement this directly on the existing Layout Block) that:
    1. Have an OnInitialize handler that calls the CheckInactiveUser Client Action;
    2. (Optional) Have an OnReady handler that uses JavaScript with setInterval to call the CheckInactiveUser Client Action at fixed time intervals;
    3. (Mandatory if you opted to implement 3. 2.) Have an OnDestroy handler that uses JavaScript with clearInterval to remove the periodic check;

If you place the InactiveUserChecker block from 3. on the Layout block (or you implemented 3. directly on your Layout block) then all your screens will be protected (and, optionally, regularly trying to check whether the user is still active).

For extra security, you probably still want all Client Actions and Server Actions to also call, respectively, CheckInactiveUser or AutoLogoutOnInactive (you don't want any logic to run when it shouldn't)

This is some overhead on your Mobile app's performance and network connectivity and should only be implemented if really mandated by your requirements.

I haven't tested any of this, hope I didn't miss any relevant details... hope it helps!