Login with Core Login API

0
Hello, I appreciate any help from you. I’m trying to log in from Java Action to support login with legacy account information. So I called ISession Session = com.mendix.core.Core.login(this.UserId, this.Password) API and it returns session object without any error, but current login user does not change, it shows anonymous user session after calling the method. How can I make it change the current user session into the session I just logged in. Thank you in advance
asked
1 answers
0

Hi Yongpyo,

you can verify the username/password with the core.authenticate, after which you can initialise the session.

Underneath a piece of code from the "forgotpassword module” which illustrates the usage.

 

ISession session = Core.initializeSession(user, (this.getSessionFromRequest(request) != null ? this.getSessionFromRequest(request).getId().toString() : null));
    
response.addCookie(this.getSessionCookieName(), session.getId().toString(),  "/", "", -1, true);
response.addCookie("XASID", "0."+Core.getXASId(),"/", "", -1, true);

answered