public override void OnActionExecuting(HttpActionContext filterContext) { // Get API key provider var provider = new CRM.Providers.TokenService(); //filterContext.ControllerContext.RequestContext.Url if (filterContext.Request.Headers.Contains(Token)) { var tokenValue = filterContext.Request.Headers.GetValues(Token).First(); // Validate Token if (provider != null && !provider.ValidateToken(tokenValue)) { var responseMessage = new HttpResponseMessage(HttpStatusCode.Unauthorized) { ReasonPhrase = "Invalid Request" }; filterContext.Response = responseMessage; } } else { filterContext.Response = new HttpResponseMessage(HttpStatusCode.Unauthorized); } base.OnActionExecuting(filterContext); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { var provider = new CRM.Providers.TokenService(); if (filterContext.HttpContext.Request.Cookies[Token] != null) { var tokenValue = filterContext.HttpContext.Request.Cookies[Token].Value; // Validate Token if (provider != null && !provider.ValidateToken(tokenValue)) { filterContext.Result = new RedirectResult(BaseUrl + "/motor/home/Acceso"); } } else { filterContext.Result = new RedirectResult(BaseUrl + "/motor/home/Acceso"); } base.OnActionExecuting(filterContext); }