alanning / MongoProviders

ASP.NET Membership and Role Providers for MongoDB
MIT License
44 stars 20 forks source link

ResetPassword() not working? #3

Open tforster opened 12 years ago

tforster commented 12 years ago

I'm using the latest version but calls to ResetPassword() to appear to persist changes to the Users collection. ResetPassword() does return a new password that observes all the password rules in web.config. But checking the Users collection shows no change in LastPasswordChangeDate or Password properties.

alanning commented 12 years ago

Hi Troy,

Hmm...normally I would guess it was not using safe mode so it was failing silently when it was performing the save. But MongoProvider's Save method explicitly uses safe mode that shouldn't be the issue.

I'd suggest trying two things:

  1. Double-check that your collections and dbs in the mongodb that you are querying match those in the web.config that MongoProvider is writing to (defaults are "users" collection and "test" database). Also note that if you have specified an application name then it will be prepended to the collection (ie. application name = "/" --> collection = "/users"). If you don't specify an application name it will default to using System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath .
  2. Compile MongoProviders in debug mode and set breakpoints in the ResetPassword and Save methods to step through and see exactly what's going on.

I'll add a test to explicitly check that the db is updated upon password reset.

Hope that helps, Adrian

tforster commented 12 years ago

Thanks Adrian,

I'm relatively new to Mongo. What is safe mode?

I have already checked the points in #1 and it all checks out properly. Interestingly enough the MembershipUser ChangePassword() method works properly. I think the next step is try compiling in debug mode as you suggested.

BTW thank you for such a great tool. I've been using the Membership API with SQL providers for about 4 or 5 years now. When switching to a NoSQL solution I looked at Raven and several others. What convinced me that Mongo was the way to go was your MongoProviders library!

alanning commented 12 years ago

Hi Troy,

Glad you find it useful! By default mongo will silently fail if database operations do not succeed. A bad default for a database in my opinion but it does allow better performance. Trouble is if people don't know about it then bad things can happen when users data suddenly doesn't get updated correctly. SafeMode means that mongo will respond to the update request with a status message indicating success or failure.

Please let me know the results of your debugging.

Regarding using NoSQL, I have really enjoyed the switch myself. You might also want to check out MongoWSAT ( https://github.com/alanning/MongoWSAT ) which provides a ready-to-go admin interface for user administration.

I've been very impressed with what I've heard about RavenDB but don't have personal experience with it. You might want to look into that a bit more if all that's holding you back is MongoProviders. :-) Support for transactions is very appealing and now that the hosted offering is live, pricing is more in line with startups' realities. I found a Membership Provider for Raven on github:

https://github.com/martijnboland/RavenDBMembership

Looks like its not really being used in production (some of the methods are not implemented and the tests could be more thorough) but might work for your use case. Also, I commented on Ayende's blog a while ago that porting MongoProviders to RavenDB would be fairly straight-forward. If you are interested I can help you with the port.

Adrian

On Wed, May 30, 2012 at 9:45 AM, Troy Forster reply@reply.github.com wrote:

Thanks Adrian,

I'm relatively new to Mongo. What is safe mode?

I have already checked the points in #1 and it all checks out properly. Interestingly enough the MembershipUser ChangePassword() method works properly. I think the next step is try compiling in debug mode as you suggested.

BTW thank you for such a great tool. I've been using the Membership API with SQL providers for about 4 or 5 years now. When switching to a NoSQL solution I looked at Raven and several others. What convinced me that Mongo was the way to go was your MongoProviders library!


Reply to this email directly or view it on GitHub: https://github.com/alanning/MongoProviders/issues/3#issuecomment-6010081

tforster commented 12 years ago

Hi Adrian, this was back-burnered for a bit while I worked on other features. Just getting back to it now. I've double checked collections and dbs and they're all correct. My next step is to compile in debug mode. I'm afraid I have a newbie question though: I added the providers references using NuGet. So, to try debug mode I downloaded the latest source from here, put it into a separate project, added the project to my solution and then tried to delete the references created by NuGet before adding a reference to the new related project. I probably don't know enough about NuGet yet to figure out how to remove it from my solution. I just keep getting invalid references to all the provider calls. Any idea how one goes about adding a reference to a local project in the solution AFTER the same project was referenced via NuGet?

I even deleted packages.config thinking that might tell VS that there's no NuGet involved and thus wake it up to using the project added to the solution.

In the mean time I have been going through the provider source for resetpassword and nothing looks unusual. It appears that it references the Mongo collection through a variable which should work. Most odd.

Troy

alanning commented 12 years ago

Hi Troy,

This project actually doesn't have a NuGet package yet. There is a different one on NuGet called MongoDB.Web that has providers. https://www.nuget.org/packages/MongoDB.Web Perhaps you installed that one?

If not and you want to get debug working here's what I recommend:

  1. Revert back to the version with all of your NuGet packages (since those are probably needed)
  2. Search through all of your projects' regular references and delete all of the references to MongoProvider
  3. Clone our latest source from github and open it in a separate instance of Visual Studio
  4. Build the Debug version of MongoProviders
  5. Manually add all of the DLLs found in the MongoProvider/bin/Debug folder into your real project

...and you should be good to go.

Please let me know how that turns out. :-)

Cheers, Adrian

On Wed, Jun 6, 2012 at 9:12 PM, Troy Forster reply@reply.github.com wrote:

Hi Adrian, this was back-burnered for a bit while I worked on other features. Just getting back to it now. I've double checked collections and dbs and they're all correct. My next step is to compile in debug mode. I'm afraid I have a newbie question though: I added the providers references using NuGet. So, to try debug mode I downloaded the latest source from here, put it into a separate project, added the project to my solution and then tried to delete the references created by NuGet before adding a reference to the new related project. I probably don't know enough about NuGet yet to figure out how to remove it from my solution. I just keep getting invalid references to all the provider calls. Any idea how one goes about adding a reference to a local project in the solution AFTER the same project was referenced via NuGet?

I even deleted packages.config thinking that might tell VS that there's no NuGet involved and thus wake it up to using the project added to the solution.

In the mean time I have been going through the provider source for resetpassword and nothing looks unusual. It appears that it references the Mongo collection through a variable which should work. Most odd.

Troy


Reply to this email directly or view it on GitHub: https://github.com/alanning/MongoProviders/issues/3#issuecomment-6166904