public override void OnActionExecuting(HttpActionContext filterContext) { // Get API key provider var provider = ServicesFactory.GetTokenServices(); 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); }
/// <summary> /// Public constructor to initialize product service instance /// </summary> public QuoteController() { _quoteServices = ServicesFactory.GetQuoteServices(); _tokenServices = ServicesFactory.GetTokenServices(); }
/// <summary> /// Public constructor to initialize product service instance /// </summary> public AuthenticateController() { _tokenServices = ServicesFactory.GetTokenServices(); _userServices = ServicesFactory.GetUserServices(); }