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

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesUserId returns -1 after progamatic loginUserId returns -1 after progamatic login
Previous
 
Next
New Post
3/19/2011 3:47 AM
 
Hi,

I'm creating a user account and logging them in from a custom registration control.

I'm having an issue because the is several other functions that rely on the UserId public shared property from DotNetNuke.Entities.Modules.PortalModuleBase and this is not update itself after the user has been logged in programmatically

This is an example of the code

    Dim objUser As UserInfo
   objUser = UserController.UserLogin(PortalSettings.PortalId, ctlUserData.Email, ctlUserData.Password, "", PortalSettings.PortalName, Request.ServerVariables("REMOTE_ADDR").ToString(), loginStatus, False)


After doing this UserId with return -1 but objUser.UserID will return the newly created UserId fine.

I've tried using the SynchronizeModule method and still no go. also tried DataCache.ClearUserCache to no avail.

Any help would be appreciated.

Thanks in Advance,

Joel

 
New Post
3/19/2011 6:19 AM
 
I found a work around for anyone experiancing the same issue.

It appears that a lot of things check the IsAuthenticated in the HttpRequest, this isn't true until another post back after the user is logged in.

There is some areas that Check the HttpContext though, also set at post back, but you can set it manually.

Got all this from looking at source

https://dotnetnuke.svn.codeplex.com/svn/Trunk/Library/Entities/Users/UserController.vb

So whats the work around?

After you've done the programmatic login you need to manually set the HttpContext like so

Dim objUser As UserInfo
objUser = UserController.UserLogin(PortalSettings.PortalId, ctlUserData.Email, ctlUserData.Password, "", PortalSettings.PortalName, Request.ServerVariables("REMOTE_ADDR").ToString(), loginStatus, False)

HttpContext.Current.Items("UserInfo") = objUser

Then instead of using the UserId property of the ModuleBase use the usercontroller, because it doens't check HttpRequest, it looks at the HttpContext.

UserController.GetCurrentUserInfo.UserID

I then had to do a find replace on serveral large files in my project, buts its working now, I can do all my steps in the one post back :)

I think taht the portalbase.vb modules should be chagned to check the HttpContext the same and the UserController Module though, this is a inconsistancy that verges on a bug in my mind.

Regards,

Joel
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesUserId returns -1 after progamatic loginUserId returns -1 after progamatic login


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