The login function is normal, when using SignOutAsync cancellation of users has been invalid, but no exception is thrown, a great god, please help to see, the code is as follows:
///& lt; Summary>
///login
///& lt;/summary>
///& lt; Param name="model" & gt;
///& lt; Returns>
[HttpPost, the Route (" Account/Login ")]
Public JsonResult LoginAsync (LoginModel model)
{
BaseResult result=new BaseResult ();
Var signInResult=Login (model. The UserName, model. The Password, the model RemenberMe);
If (signInResult. IsNotAllowed)//account is not enabled
{
Result. The ResultCode=Resources. Tips. LoginTips. SignInUserNotAllowedCode;
Result. The ResultMsg=Resources. Tips. LoginTips. SignInUserNotAllowedMsg;
}
Else if (signInResult IsLockedOut)//account locked
{
Result. The ResultCode=Resources. Tips. LoginTips. SignInUserLockedCode;
Result. The ResultMsg=Resources. Tips. LoginTips. SignInUserLockedMsg;
}
else if (! SignInResult. Succeeded)
{
Result. The ResultCode=Resources. Tips. LoginTips. SignInPasswordOrUserNameErrorCode;
Result. The ResultMsg=Resources. Tips. LoginTips. SignInPasswordOrUserNameErrorMsg;
}
If (result. The ResultCode==monObjectSuccessCode CommonTips.Com
{
LogService. WriteLog (model. The UserName, ValueHelper NowTime + ", IP: "+ HttpContext. GetClientUserIp ()," success ", "login", "account management");
}
The else
{
LogService. WriteLog (model. The UserName, ValueHelper NowTime + ", IP: "+ HttpContext. GetClientUserIp () + result. ResultMsg," failure ", "login", "account management");
}
return Json(result);
}
//& lt; Summary>
///logout
///& lt;/summary>
[the Route (" Account/Logout ")]
Public IActionResult LogoutAsync ()
{
String userId.=HttpContext GetUserId ();
Logout ();
LogService. WriteLog (userId, ValueHelper NowTime + ", IP: "+ HttpContext. GetClientUserIp ()," success ", "logout", "account management");
Return RedirectToAction (" Index ");
}
///& lt; Summary>
///login
///& lt;/summary>
///& lt; Param name="username" & gt;
///& lt; Param name="PWD" & gt;
///& lt; Returns>
Public SignInResult Login (string username, string PWD, bool remenberMe)
{
Return SignInManager. PasswordSignInAsync (username and PWD, remenberMe, false), the Result;
}
///& lt; Summary>
///logout
///& lt;/summary>
///& lt; Returns>
Public async void Logout ()
{
Await SignInManager. SignOutAsync ();
}
CodePudding user response:
Problems may appear on the redirect...CodePudding user response:
Whether you exit code to add the log normal output? If the output, and explain the cancellation code executionCodePudding user response:
Identity exit is need in the form form, it is need a Token validation,Page Views:
- Hello! @ getUser. ChineseName
-