Reputation: 9043
Is there a quick way to verify is user exists and based on existence of user name get user id?
(i.e. the user only has the user name and the adds it to change their password)?
I would think something like this... String userId = User.Identity.GetUserId(userName);
I am looking for a quick way for local users to change their password if need be.
Upvotes: 1
Views: 2898
Reputation: 9043
Have it, thanks
var user = UserManager.FindByName(userName);
String userId = user.Id;
Upvotes: 0
Reputation: 20383
User.Identity.GetUserId()
will return the id of current logged in user.
From UserManager
you can get any user from their username like this
var user = UserManager.FindByName("the username here");
then you can change password from UserManager
again
UserManager.ChangePassword(user.Id, "OldPassword", "NewPassword");
Upvotes: 2