Identity icon indicating copy to clipboard operation
Identity copied to clipboard

Why does HashPassword take in TUser as parameter?

Open henningst opened this issue 10 years ago • 3 comments

The HashPassword method in https://github.com/aspnet/Identity/blob/dev/src/Microsoft.AspNetCore.Identity/PasswordHasher.cs takes in both TUser and plain text password as params, but the user param is never used. This seems to be something new that is added in the AspNetCore implementation. Why?

henningst avatar Apr 07 '16 10:04 henningst

This is so custom implementations can access things off of the user if they so desire as part of the hashing operation, for example if they wanted the salt to live on the user entity. By default we don't use this behavior but it was requested to enable more advanced scenarios.

HaoK avatar Apr 11 '16 20:04 HaoK

Shouldn't IPasswordHasher<TUser> have an overload without TUser then?

akamud avatar May 13 '16 13:05 akamud

Just ignore it if your hasher implementation doesn't care about the user instance.

HaoK avatar May 17 '16 19:05 HaoK