public Result Check(LoginModel input) { Result result = Result.Create(); if (!ModelState.IsValid) { throw new Exception(ModelState.Values.Where(x => x.Errors.Count > 0).Select(x => x.Errors).FirstOrDefault().Select(x => x.ErrorMessage).FirstOrDefault()); } var validate = WebSecurityHelper.ValidateUser(input.username, input.password, input.remember, () => { var user = _sysUserServices.GetUserByName(input.username); if (user == null) { throw new Exception("账户不存在"); } var systemUser = new Operator() { Id = user.Id, UserName = user.Name, Password = user.Password, Name = user.LoginName, IsAdministrator = user.Isadmin == 1 }; switch (user.State) { case 1: throw new Exception("账户被禁用"); case -1: throw new Exception("账户不存在"); } return(systemUser); }); return(validate); }