c# - 如何使用 Identity 自定义登录方法
问题描述
我有一个派生自 IdentityUser 的元素,其中包含一个名为 AppId 的属性。我正在尝试自定义 SignInManager.PasswordSignInAsync,因此它包含 AppId(来自 AspNetUsers,其中 AppId = id)。
这甚至可能吗?
到目前为止我所拥有的:
public class LCUserManager
{
public LCUserManager(IdentityDbContext context)
{
this.DbContext = context;
}
public async Task<IProfile> SignIn(int appId, string userName, string password)
{
IProfile result = default;
PasswordHasher<Profile> hash = new PasswordHasher<Profile>();
var tmp = this.DbContext.Profiles.SingleOrDefault(u => u.Active && u.AppId.Equals(appId) && u.NormalizedUserName.Equals(userName.ToNormalized()));
if (tmp != default)
{
}
else
{
}
}
public IIdentityDbContext DbContext { get; }
}
解决方案
推荐阅读
- scrollmagic - 在scrollmagic中,我将如何固定一个场景,在该场景中发生动画,然后让下一个场景滚动它?
- swift - 莫哈韦沙漠上的 Swift 5.2
- azure - 函数发布到门户后,Azure 函数在函数列表中不可见
- next.js - 使用 next.js 进行参数化动态导入
- javascript - 将动画与 Javascript 和 CSS 混合
- r - UniprotR包如何使用GetProteinAnnontate函数?
- node.js - SQL Server Management Studio (SSMS) 数据库连接到 NodeJS
- python - Python - XML:为每个父母分离兄弟姐妹
- javascript - 使用 Javascript Map 或 Filter Method 根据从复杂 JSON 结构中选择的 id 显示国家/地区
- docker - pytest-cov ERROR 导入文件不匹配导致heroku存储库中的旧目录,无法删除目录