Apr 16 2006

DotNetNuke Module - FixLogin

Category: DotNetNukeBil@l @ 13:53

In a new DotNetNuke 3.2.2 website I am working on, supposedly will be online this coming week, I faced the following problem:

DotNetNuke uses by default a Login Page. So, when users come to sign in, if authenticated they will be redirect to the page they were accessing it.

The problem with the default Login page is that, all modules added to the different areas of the site, we will not be shown when the login page is displaying.

To overcome this problem, I created a new page, with all the needed modules placed in their locations, and placed an Account Login module. Then through the Site Settings, I made this page the *Login Page* of the website.

Now users, when they come to login, they will be using my custom login page, showing all modules in their proper locations, as if the login page now, acts like any other page in the website, with the exception, it is being used to login users.

Another problem arises here!!

What happens now is that, when users sign in, they are redirected to the custom login page, which is something that confuses users, since they have just signed in, and now they are faced with the login page again.

My analysis for this problem is that, the Account Login module is functioning normally, it has redirected users to the previous page coming from, and this is ok. However, it seems that the DNN default Login page and the Account Login Module act as single component, so the page and the module is one single component, and hence the Account Login module will not consider the DNN default login page as a previous page coming from, and it will function as required. 


So, having this problem of the custom login page, forced me to look for some help online, however, could not find it. I had to solve it on my own. 

How?


I created a simple module, called FixLogin. This module is free to download and use and can be found at:
https://bhaidar.net/cs/files/5/april/entry270.aspx 

What this module does, is check if the Current Request is authenticated, if true, and then redirects the user to a page. This page can be set by using the module settings itself.

Once you add a new module definition, you will need to add two controls:

  • FixLogin.ascx
  • FixLoginSettings.ascx

The first is the default control, which should not have any key associated with it and is of type View. The second control is the settings control. 

Now, you can place this module on the custom login page you have in your website. Make sure to configure the settings of this module before using it. If you didn’t configure the module, no redirect will happen.

From the Action’s menu of the module, go to Settings, and specify the page to redirect to if the request is authenticated.