Ejemplo n.º 1
0
        /// <summary>
        /// Check if Token is Authenticated With User ID
        /// </summary>
        /// <returns></returns>
        private bool IsTokenAuthenticated()
        {
            HttpRequestHeaders headers      = this.Request.Headers;
            string             _headerToken = string.Empty;

            if (headers.Contains("header_token"))
            {
                _headerToken = headers.GetValues("header_token").First();
            }
            if (headers.Contains("user_id"))
            {
                _userId = Convert.ToInt32(headers.GetValues("user_id").First());
            }

            User_BLL _objUserBll = new User_BLL();

            if (_headerToken == string.Empty || _userId == 0)
            {
                _strJSONContent.Append("{\"status\":\"UnAuthorized\"}");
                return(false);
            }
            else if (!(_objUserBll.IsTokenAuthenticated(_headerToken, _userId)))
            {
                _strJSONContent.Append("{\"status\":\"UnAuthorized\"}");
                return(false);
            }
            else
            {
                return(true);
            }
        }