How to create a session for from anonymous user to known user, and to a specific page?

0
Hi guys,   I have exposed a rest service wherein I validate the user with another thirth party integration. Based on this validation I find the associated account for the anonymous user and want to send the user to a specific page accessible for a specific role (Customer). So how can I create a session for the associated account of the customer user while he is still anonymous? And can i send then when Mendix recognized the logged in user as customer (created session)  to a specific page, before Mendix directs to the homepage?
asked
2 answers
2

If you have an anonymous user, and you have the user you want to create a session for (i.e. the system.user object from your database, which is a generalization of your account), you can create a Java action (UpgradeSession) with the system.user object that you want to upgrade the session to.

 

The Java action should contain the following code.

		// BEGIN USER CODE
		IContext systemContext = Core.createSystemContext();
		UUID currentSessionId = this.getContext().getSession().getId();
		IUser iUser = Core.getUser(systemContext, user.getName());
		Core.initializeSession(iUser, currentSessionId.toString());
		return true;		
		// END USER CODE

After you have upgraded the session, you can show a page with the URL redirector widget, redirecting the user to your application's root URL.

Note: this only works in Mendix 6, for Mendix 7 you require a request handler.

answered
-1

I think the deeplink module would be a good option. This deeplink should open the page that is not available for an anonymous user. Use the URL redirect to trigger the deeplink. Since the user is anonymous the deeplink will handle the login and continuation to the page.

You probably could also use the permanent link as described here: https://docs.mendix.com/refguide6/page

See the URL part. As far as I know if the current user does not have enough rights it will also do a login. I have not yet played with that concept myself a lot so you should try if this also works.

Regards,

Ronald

 

answered