public async Task <IActionResult> CheckLogin(LoginParam loginModel) { if (loginModel != null && loginModel.UserName.IsNotNullOrEmpty() && loginModel.UserPwd.IsNotNullOrEmpty() && loginModel.UserCode.IsNotNullOrEmpty()) { if (MD5Encrypt.MD5By16(loginModel.UserCode.ToLower()) != webHelper.GetSession(workContext.UserKey)) { messages.Msg = "验证码错误,请重新输入"; } else { var result = await userService.Login(loginModel.UserName, loginModel.UserPwd); if (result.Succeeded) { //记住登录凭证 var claims = new List <Claim> { //用户编号||用户名 new Claim(ClaimTypes.Name, result.UserId.ToString() + "|||" + loginModel.UserName) }; ClaimsIdentity userIdentity = new ClaimsIdentity(claims, "login"); ClaimsPrincipal principal = new ClaimsPrincipal(userIdentity); await HttpContext.SignInAsync(principal); //缓存权限 await userCacheService.SetPermissionCacheAsync(result.UserId); } messages.Success = result.Succeeded; messages.Msg = result.Msg; } } else { messages.Msg = "请填写完整"; } return(Json(messages)); }