Adding user role after sign-in

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
3/14/2012 11:33:13 PM
Gravatar
Total Posts 10

Adding user role after sign-in

Hi all,

I have created a custom handler which redirects to a page if certain criteria have never been set for the user.  I guess you could consider it a second stage in the registration process as I didn't want to alter any of the mojoPortal code and the custom profile fields didn't really allow for what I needed to do.

Anyway, the user is required to enter some additional data and when the page is submitted they are assigned a mojoPortal Role according to their selections.  Basically the client wants to customise the content based on this.

I think the concept works well, only the Roles appear to be cached and it is bit untidy to prompt the user to sign out and back in so they pick up the new Role.

Is there any way to force the users role list to reload programatically when I add the new role for the user to avoid the need to sign-out/in?

Cheers!

Chris

3/14/2012 11:38:28 PM
Gravatar
Total Posts 2253

Re: Adding user role after sign-in

As of mojo 2.3.8.1, the role cookie is automatically updated on the next authenticated page request. So, you shouldn't need to have the user logout/login. They will just need to refresh their page.

HTH,
Joe D.

3/15/2012 12:11:55 AM
Gravatar
Total Posts 10

Re: Adding user role after sign-in

Ah, thanks for that Joe D.

For this particular client we are still on a legacy version of mojoPortal, basically the last version that ran under Visual Studio 2008.

Maybe I'll have to recommend that we migrate them to the latest version to get this functionality.

Cheers,

Chris

3/15/2012 7:20:35 AM
Gravatar
Total Posts 18439

Re: Adding user role after sign-in

In an older version you can still do it from custom code depending on how old it is the method to reset the role cookie may exist on mojoRoleProvider so after adding the user to roles you would call:

mojoRoleProvider.ResetCurrentUserRolesCookie();

It will reset the role cookie for the current user viewing the page and on the next request for a page the new roles will be active. I'm not sure if that method will exist in your version, it has been a long time since we supported VS 2008 and this method may have been added after that I'm just not sure.

In the latest version we have a RolesChanged property on SiteUser so all you do is set it to true and save the user after making any role changes on the user. on the next request by the user the same method will be called automatically to reset the cookie and then RolesChanged will be set back to false.

Hope that helps,

Joe

You must sign in to post in the forums. This thread is closed to new posts.