public async Task <IActionResult> CheckLogin(LoginModel loginModel) { var messages = new Messages(); if (loginModel != null && loginModel.UserName.IsNotNullOrEmpty() && loginModel.UserPwd.IsNotNullOrEmpty() && loginModel.UserCode.IsNotNullOrEmpty()) { if (MD5Encrypt.MD5By16(loginModel.UserCode.ToLower()) != webHelper.GetStrSession(loginModel.UserCode.ToUpper())) { messages.Msg = "验证码错误,请重新输入"; } else { var result = await adminSvc.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); //缓存权限 //userCacheService.SetPermissionCache(result.UserId); } messages.Success = result.Succeeded; messages.Msg = result.Msg; } } else { messages.Msg = "请填写完整"; } return(Json(messages)); }