我正在自己实现IUserPasswordStore<TUser,TKey>
,阅读和创建操作正常。除了UserManager.Create(TUser,Password)
重载不添加任何密码。我对它应该如何实现有点不确定,我猜想重载会调用IUserPasswordStore.CreateAsync
然后调用IUserPasswordStore.SetPasswordHashAsync
但是情况似乎并非如此。它只会调用前一种方法,即使使用重载提供密码也不会设置密码。
以下是我IUser<TKey>
的实现:
[<AllowNullLiteral>]
type ApplicationUser(id, email) =
member __.Id = id
member __.Email = email
member val PasswordHash = Unchecked.defaultof<string> with get,set
new(email) = ApplicationUser(0, email)
interface IUser<int> with
member __.Id = id
member val UserName = email with get,set
IUserPasswordStore.CreateAsync
只是针对数据库运行此查询:
INSERT INTO dbo.Users(Email,PasswordHash) VALUES (@email, @pwHash)