Reputation: 53
I site up using the default authentication that does standard in the visual studio 2015 default project. I registered a user, checked that I could login, logoff etc and all was fine.
However I then changed a field in one of my classes from something else to applicationUser and this required a database update. After the update my user was still in the database but will not return via ApplicationDbContext. Each new user I create is fine, but the first exists in the database only.
After I create a few more users I tried updating the password of one via ApplicationDbContext.Users and this saw that user disappear from results but not the database also.
So I have two questions, why did this occur and what is the correct method for updating things like user passwords, email etc?
For some example code:
user = await store.FindByNameAsync("[email protected]");
DB.Users.ToList()
Neither of the above return the user of that email (username is the email) but it absolutely IS in the database.
Upvotes: 0
Views: 102
Reputation:
For changing password in asp.net identity use this code:
ApplicationUser user = await store.FindByIdAsync(userId);
await store.SetPasswordHashAsync(user, hashedpwd);
await store.UpdateAsync(user);
Upvotes: 1