Logout user after 8 hours

0
I found a way of logging out a user after x seconds of idle time (by adding the variable SessionTimeout to the m2ee.yaml file) Now I am trying to logout a user after 8 hours, even if session is not idle.  Any ideas on how to do this? apparently m2ee doesn’t not have a setting for this.    I heard it is possible to use a java action call, but I am not sure how to implement this. Does anyone have any examples to share? 
asked
3 answers
2

This is the Java code to log a user out:

// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
// Special characters, e.g., é, ö, à, etc. are supported in comments.

package basis.actions;

import com.mendix.systemwideinterfaces.core.UserAction;
import com.mendix.systemwideinterfaces.core.IContext;
import com.mendix.webui.CustomJavaAction;

/**
 * Dit is een simpele uitlog java actie.... 
 */
public class LogOut extends CustomJavaAction<java.lang.Boolean>
{
	public LogOut(IContext context)
	{
		super(context);
	}

	@java.lang.Override
	public java.lang.Boolean executeAction() throws Exception
	{
		// BEGIN USER CODE
    com.mendix.core.Core.logout(getContext().getSession());
    com.mendix.webui.FeedbackHelper.addLogoutFeedback(getContext());
    return true;
		// END USER CODE
	}

	/**
	 * Returns a string representation of this action
	 */
	@java.lang.Override
	public java.lang.String toString()
	{
		return "LogOut";
	}

	// BEGIN EXTRA CODE
	// END EXTRA CODE
}

The user that triggers this Java code is logged out. You could use this in combination with the community commons executeMicroflowAsUser.

Regards,

Ronald

 

answered
0

Thank you for your answer. I am pretty new to mendix.

I right clicked, add other/javascript action. Pasted the code and I got a ton of errors.

 

answered
0

Now I have both pieces and I just need to put them together. 

  • your script logs out users
  • I have a microflow that checks if the user has been logged in for more than 8 hours and if so, it adds it to the “session list”.

 

How do I delete the sessions listed in this list? 

 

answered