How do I take text from input element of a form and put it in AspNetUsers table properly?
I'm passing it from view to controller action through parameters, if that's relevant. This input element has to have the attribute
type="password"
btw (it is a password) and I would like to be able to hash the text input in it like the system does and put it into AspNetUsers and also take what's already there and unhash it. I'm doing this cause I want to give the user a way to change their current password to a new one, if there is a better way I'm open to suggestions.5 Replies
You do not "unhash"
That's the point, hashes are one-way only
Since you have
AspNetUsers
, you're using Identitydoesn't identity already handle passwords?
If so, use
UserManager
methods
Yes it does
UserManager
has methods for login, register, change password, and so oneven if you need another password-like field, you can use identity's password hasher
that will use an appropriately implemented hashing algorithm
for basic account management identity should handle all the basic use cases for you already
trying to inject usermanager into the relevant controller like this:
But Visual Studio doesn't recognize the UserManager<IdentityUser> type. When I change it to
private Microsoft.AspNet.Identity.UserManager<IdentityUser> _userManager;
I get this error:
'Microsoft.AspNetCore.Identity.IdentityUser' cannot be used as type parameter 'TUser' in the generic type or method 'UserManager<TUser>'. There is no implicit reference conversion from 'Microsoft.AspNetCore.Identity.IdentityUser' to 'Microsoft.AspNet.Identity.IUser<string>'.
@jIMMACLE @ZZZZZZZZZZZZZZZZZZZZZZZZZ