Ejemplo n.º 1
0
        /// <summary>
        /// 验证
        /// </summary>
        /// <param name="actionContext"></param>
        /// <returns></returns>
        protected override bool IsAuthorized(HttpActionContext actionContext)
        {
            var ts = actionContext.Request.Headers.Where(c => c.Key.ToLower() == "token").FirstOrDefault().Value;

            if (ts != null && ts.Count() > 0)
            {
                var token = ts.First <string>();
                if (!TokenResultMsg.IsExistToken(token))
                {
                    return(false);
                }
                return(true);
            }
            if (actionContext.Request.Method == HttpMethod.Options)
            {
                return(true);
            }
            return(false);
        }