Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeGetting StartedGetting StartedNew to DNN Plat...New to DNN Plat...Can you force a login from a module?Can you force a login from a module?
Previous
 
Next
New Post
9/1/2011 12:04 PM
 
I'm working on a module in which at a certain point I need to have the user log onto the site if they are not already logged in.  How would I determine if they are logged in?  AND is it possible to force them to login and have them return to the same module?  I'm coding for DNN 5.5. OR is it possible to insert the standard Account Login functionality into my module with a control?  Any help appreciated.
 
New Post
9/1/2011 12:31 PM
 
Arlene, a few options:

1. Use DNN page level security to restrict to registered users (on the page your module will be shown on) and let DNN handle the login redirect for non authenticated users.

2. Do the same on your module level settings...but you won't get the redirect...it just won't show to non authenticated users but you can display a message to unauthenticated users telling them to login or just show the login.

3. You can check for a userid in code and if it's -1 the user is not logged in.  You can then build a redirect to the login page and even include the return url info.

Something along these line would do it

if (UserId == -1)
            {
                PortalSettings MyPortalSettings = PortalController.GetCurrentPortalSettings();
                Response.Redirect(Globals.NavigateURL(MyPortalSettings.LoginTabId));
            }


Yes you can create your own login.   I don't have any code examples handy but it's doable....just look at the source for the core login.


Steven Webster
Manager, Community Platform
F5 Networks, DevCentral
 
New Post
9/1/2011 2:45 PM
 
First of all, I want to thank you for a VERY complete answer.  You covered all of the bases. 

I have tried converting your C# example to VB but I'm still having problems getting the code to work.  It seems to be redirecting to the same page but never bringing up the Login page.

I added an import reference:
Imports DotNetNuke.Entities.Users

In my subroutine I added the following variable:
Dim MyPortalSettings As PortalSettings = PortalController.GetCurrentPortalSettings()

I have verified that the UserID is indeed -1.

I added the following code for the redirect:
If UserInfo.UserID = -1 Then
     Response.Redirect(Globals.NavigateURL(MyPortalSettings.LoginTabId))
End If

The code beneath the above code is not being executed. But the page refreshes and any messages that I had displayed disappear so it's coming back to the same page.  It just doesn't ever bring up the Login page.

Any idea of what I'm doing wrong?  Perhaps something has been lost in the translation? Again I appreciate your help.
 
New Post
9/1/2011 3:08 PM
 
This might be helpful: http://adefwebserver.com/dotnetnukehelp/NavigateURL/

Also, two silly questions. Do you have a login page define in site settings? Are you attempting this as an anonymous user?



Steven Webster
Manager, Community Platform
F5 Networks, DevCentral
 
New Post
9/1/2011 4:06 PM
 
I will check out the article.

As far as the questions go - I'm not sure they are silly. I didn't know that you had to specify a Login Page.  I do not have one specified.  However, I also don't see the standard Login page listed as a page on the site. Am I right is assuming that I should create a page of my own and add the Account Login module to the page?

As far as the anonymous user question - if I understand the question correctly - I'm going to the site, accessing a page with the module I'm building on it, doing some work on that page and once it gets to a certain place in the module processing I want the user to login before continuing - sort of like a checkout process in a store.  Is that what you were asking about?

Again, thanks for the help and I apologize for my 'newness' to this platform.
 
Previous
 
Next
HomeHomeGetting StartedGetting StartedNew to DNN Plat...New to DNN Plat...Can you force a login from a module?Can you force a login from a module?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out