//[ServiceFilter(typeof(ValidateTokenAttribute))] public IActionResult GetAuth([FromBody] LoginRequestModel loginRequest) { loginRequest.Username = loginRequest.Username.Trim(); loginRequest.Password = MD5Encrypting.MD5Encrypt64(MD5Encrypting.MD5Encrypt16(loginRequest.Password.Trim()));//两次加密安全性更高 ResponseResult responseResult = CommonFactory.CreateResponseResult; UserModel user = _userService.GetUser(loginRequest); if (user == null || user.IsDelete == DataStatusEnum.Delete) { return(Ok(responseResult.Failed("用户名或者密码错误"))); } if (user.AccountStatus == AccountStatusEnum.PendingReview) { return(Ok(responseResult.Failed("账号待审核通过中"))); } if (user.AccountStatus == AccountStatusEnum.Locked) { return(Ok(responseResult.Failed("账号已被锁定"))); } if (user.AccountStatus == AccountStatusEnum.Forbidden) { return(Ok(responseResult.Failed("账号已被禁用"))); } string token = _authService.CreateToken(new AuthContext() { ID = user.ID, Username = user.Username, Email = user.Email, Role = "testRole", }); return(Ok(responseResult.ResponseData(token))); }