Auto Login in Mendix

0
Hello Experts,  I have a web application with login using LDAP, here I have a requirement where I need to login for the first time and whenever I try to open the application for the second time by entering only the APP URL it should not ask me to login again instead it should take me to the specific dashboard which I already logged in. Similar to remember me or auto login concept, even if I restart the system and open the app again it should not ask for a login since it’s a second time.  Is there any way to implement it. Also when the user clicks on sign out button the user still remains logged in on the same page. Thanks in Advance! Answers are really much appreciated.
asked
2 answers
0

So basically you want to persist the session at the application, which you could probably do with a cookie?

answered
0

Hey Arunkumar Jaganathan,

This following part is for coockie

You can accomplish this by running the application locally and navigating to the folder MendixApp/Deployment/Web/Index.html. In that location, you will find a section that is automatically generated for cookies. It should resemble the following:

if (!document.cookie || !document.cookie.match(/(^|;) *originURI=/gi)) document.cookie = "originURI=/login.html" + (window.location.protocol === "https:" ? ";SameSite=None;Secure" : "");

You can copy that part and paste it (within the script section) into your Index.html file, which can be found in the folder MendixApp/theme/web/Index.html. If this doesn't resolve the issue, you may need to make some changes to the mentioned code.

 

And in addition you should create custom logic where you should add boolean to account entity that can be called IsFirstLogin and in navigation you wanna go to Home pages -> Roile-based home pages where you can create microflow that will check that boolean and redirect user to Home screen or login page.

image.png

Best regards

answered