public override void OnAuthorization(HttpActionContext actionContext) { //如果用户方位的Action带有AllowAnonymousAttribute,则不进行授权验证 if (actionContext.ActionDescriptor.GetCustomAttributes <AllowAnonymousAttribute>().Any()) { return; } string userid = CRequest.GetString("userid"); string token = CRequest.GetString("token"); string openid = CRequest.GetString("openid"); if (userid == "" || token == "" || openid == "") { actionContext.Response = ResponseStr.ToJsonError("9", "未登陆"); } else { Log.WriterLog(userid + "--" + token + "--" + openid); openid = CTools.GetOpenId(openid); if (!token.Equals(CTools.GetMD5FromString(userid + openid + "SSXXCJYXGS"))) { actionContext.Response = ResponseStr.ToJsonError("9", "非法请求"); } } }
public object QueryById([FromBody] Newtonsoft.Json.Linq.JObject obj) { if (obj["userid"] == null || obj["userid"].ToString() == "") { return(ResponseStr.ToJsonError("参数错误")); } WxUserInfoBLL bll = new WxUserInfoBLL(); List <WxUserInfo> users = bll.QueryUserInfoByID(int.Parse(obj["userid"].ToString())); if (users != null && users.Count > 0) { return(ResponseStr.ToJsonTrue(users[0])); } else { return(ResponseStr.ToJsonError("查不到用户信息")); } }