redirecting to the website's pages based on username after successful login

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.
8/15/2012 11:51:30 AM
Gravatar
Total Posts 5

redirecting to the website's pages based on username after successful login

Hi,

I'm trying to create an area for each of our clients where they can upload their private documents. This page should be only available to the one who has uploaded the file and for security reasons the page title is not shown in the site menu.

I followed this tutorial and it is done. what is remained is that each of the clients should be redirected to his own page after logging in (because the page is not included in the site menu).

How is this possible?

Cheers.

David

 

 

 

8/15/2012 2:35:35 PM
Gravatar
Total Posts 1203
Proud member of the mojoPortal team

Help support mojoPortal!
Add-on modules

Re: redirecting to the website's pages based on username after successful login

This can be done with a bit of custom programming. You'd create a User Sign In Event Handler. Within that handler, you just need to do a redirect based on the user's ID, or whatever you use to determine which page they are assigned to.

Jamie

8/16/2012 1:22:48 PM
Gravatar
Total Posts 5

Re: redirecting to the website's pages based on username after successful login

Hi Jamie,

Thank you for your quick response. This is exactly what I need, but I spent all today and I could not compile the Mojoportal source code to create the custom dll.

I downloaded the source code from CodePlex, and tried to modify DoNothingUserSignInHandlerProvider.cs which is located in wwwroot\mojoPortal.Business.WebHelpers\UserSignInHandlers folder. But It wont compile and I get lots of errors originating from web.config.

Am I doing it right?

Best,

David

8/16/2012 1:29:30 PM
Gravatar
Total Posts 18439

Re: redirecting to the website's pages based on username after successful login

The download links that codeplex generates for the source code should not be used, it isn't a reliable way to get the code. You should clone the repository using TortoiseHG.

But you should not modify any mojoPortal code, custom code should be in your own separate projects.

See

Hope that helps,

Joe

8/18/2012 10:00:32 AM
Gravatar
Total Posts 5

Re: redirecting to the website's pages based on username after successful login

Thank you Jamie and Joe

I added this code to DoNothingUserSignInHandlerProvider.cs and compiled it.

 if (e.SiteUser.LoginName.ToString() != "admin")
          System.Web.HttpContext.Current.Response.Redirect(string.Format("http://www.URL.com/{0}.aspx",e.SiteUser.LoginName.ToString()));


I couldn't figure out how to create a separate project and attach it to MOJO; so, I Forked the source code only a little.

Best,

8/20/2012 11:44:45 AM
Gravatar
Total Posts 18439

Re: redirecting to the website's pages based on username after successful login

You should not fork the code, especially for some small little thing that can be easily done without forking the code. You are creating difficulties for yourself doing that, making it harder to upgrade to new versions and adding unneccesary maintainenance tasks to keep your customization.

1. copy and rename the mojoportal.sln file as discussed in the article Setting Up Your Projects

2. add a class library to your custom .sln file

3. add a reference in your class library to the mojoPortal.Business and mojoPortal.Business.WebHelpers projects

4. add a class to your class library and copy in the code from the DoNothingUserSignInHandler, but rename the class and the namespace. Now this class library can be compiled into its own dll which can be put in the /bin folder of mojoPortal.Web project

5. finally make a custom config file that references your namespace and class as indicated in the article User Sign In Event Handlers, and put that file under Web/Setup/ProviderConfig/usersigninhandlers

If you go down the path of forking the code you will later regret it when you need bug fixes or new features.

Best,

Joe

8/24/2012 1:20:42 AM
Gravatar
Total Posts 5

Re: redirecting to the website's pages based on username after successful login

Hi Joe,

Thank you for the nice and detailed tutorial.

Cheers,

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