[英]How to find out the reason for failed signing in, when ASP.NET Core fails to sign in?
I'm using ASP.NET Core Identity to manage users.我正在使用 ASP.NET Core Identity 来管理用户。 And I get this response when I'm trying to sign-in a user:
当我尝试登录用户时,我收到此响应:
{
type: "Error",
message: "Not logged in",
data: {
succeeded: false,
isLockedOut: false,
isNotAllowed: false,
requiresTwoFactor: false
}
}
As you can see, user is not logged in, and no other reason is true .如您所见,用户未登录,并且没有其他原因为true 。
What should I do now to find out "why" user has not logged in?我现在应该怎么做才能找出“为什么”用户没有登录? How to find the error here?
如何找到这里的错误?
The method I'm using is PasswordSignInAsync
and the result it returns is SignInResult
and it does not have a field for the error description.我使用的方法是
PasswordSignInAsync
并且它返回的结果是SignInResult
并且它没有用于错误描述的字段。
The method I'm using is PasswordSignInAsync and the result it returns is SignInResult and it does not have a field for the error description.
我使用的方法是 PasswordSignInAsync 并且它返回的结果是 SignInResult 并且它没有用于错误描述的字段。
To troubleshoot the issue, you can refer to the following code snippet to check if user is existing/registered, then check if the given password is valid for the specified user.要解决此问题,您可以参考以下代码片段来检查用户是否存在/注册,然后检查给定的密码对指定用户是否有效。
//check if user is existing
var user = await _userManager.FindByEmailAsync(Input.Email); //or .FindByNameAsync(username_here)
//check if pwd is valid
var pwd_is_valid = _userManager.CheckPasswordAsync(user, Input.Password);
And, you can try to debug your code and check if any useful logs are written to output window.而且,您可以尝试调试代码并检查是否有任何有用的日志写入输出窗口。
Besides, you can try to register a new user and login with that new user's account to check if it can work well.此外,您可以尝试注册一个新用户并使用该新用户的帐户登录以检查它是否可以正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.