コード例 #1
0
        private bool AuthorizeToken(HttpActionContext actionContext)
        {
            try
            {
                var encodedString = actionContext.Request.Headers.GetValues("Token").First();

                bool validFlag = false;

                if (!string.IsNullOrEmpty(encodedString))
                {
                    objBLLMApiUser.Token  = encodedString;
                    objBLLMApiUser.Sptype = 1;
                    int UserCount = objBLLMApiUser.ExecuteNonQuery(objBLLMApiUser);

                    if (UserCount > 0)
                    {
                        validFlag = true;
                    }
                }
                return(validFlag);
            }
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #2
0
ファイル: ActionFilters.cs プロジェクト: yogeshjuneja/testapi
        public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
        {
            BLLMApiUser objBLLMApiUser = new BLLMApiUser();

            objBLLMApiUser.Sptype         = 3;
            objBLLMApiUser.IP             = GetClientIpString(actionExecutedContext);
            objBLLMApiUser.Token          = actionExecutedContext.Request.Headers.GetValues("Token").First();
            objBLLMApiUser.ResponseObject = actionExecutedContext.Response.Content.ReadAsStringAsync().Result;
            objBLLMApiUser.RequestObject  = actionExecutedContext.Request.RequestUri.Query.ToString();
            objBLLMApiUser.RequestUrl     = actionExecutedContext.Request.RequestUri.ToString();
            objBLLMApiUser.ExecuteNonQuery(objBLLMApiUser);
        }
コード例 #3
0
        private bool AuthorizeToken(HttpActionContext actionContext)
        {
            bool IsAuthorized = false;

            try
            {
                objBLLMApiUser.Sptype       = 2;
                objBLLMApiUser.ActionMethod = actionContext.ActionDescriptor.ActionName;
                objBLLMApiUser.Controller   = actionContext.ControllerContext.ControllerDescriptor.ControllerName;
                objBLLMApiUser.Token        = actionContext.Request.Headers.GetValues("Token").First();

                int Result = objBLLMApiUser.ExecuteNonQuery(objBLLMApiUser);
                if (Result == -200)
                {
                    IsAuthorized = true;
                }
                return(IsAuthorized);
            }
            catch (Exception)
            {
                return(false);
            }
        }