Beispiel #1
0
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            RequestResult result = new RequestResult();

            // 请求限制间隔

            HttpContextBase context = (HttpContextBase)actionContext.Request.Properties["MS_HttpContext"];//获取传统context
            HttpRequestBase request = context.Request;

            if (!IsOpenApi)
            {
                if (request["UserToken"] == null)
                {
                    result.code            = 101;
                    result.message         = "无法验证用户密钥.";
                    actionContext.Response = GetHttpResponseMessage(result);
                }
                else
                {
                    string UserToken = request["UserToken"].ToString();
                    if (PDAUserMsg.TokenGetUser(UserToken) == null)
                    {
                        result.code            = 101;
                        result.message         = "用户密钥已过期或不存在.";
                        actionContext.Response = GetHttpResponseMessage(result);
                    }
                }
            }
        }
Beispiel #2
0
        protected override void Initialize(HttpControllerContext controllerContext)
        {
            HttpContextBase context = (HttpContextBase)controllerContext.Request.Properties["MS_HttpContext"];//获取传统context
            HttpRequestBase request = context.Request;

            if (request["UserToken"] != null)
            {
                UserToken = request["UserToken"].ToString();

                if (!string.IsNullOrWhiteSpace(UserToken))
                {
                    CachePDAUser User = PDAUserMsg.TokenGetUser(UserToken);
                    if (User != null)
                    {
                        PdaUser = PDAUser.GetEntityByID(User.UserID);
                    }
                }
            }

            base.Initialize(controllerContext);
        }