private bool ValidAccessToken(ActionExecutingContext context, string accessToken) { context.HttpContext.Items[AuthorizationHeaderName] = accessToken; if (cacheProvider == null) { cacheProvider = (IDisctributedCacheProvider)context.HttpContext.RequestServices.GetService(typeof(IDisctributedCacheProvider)); } //get user from distributed cache User user = cacheProvider.Get <User>(accessToken); if (user != null) { //there, we can cache user object to http context. return(true); } return(false); }
public LoginController(LoginService loginService, IDisctributedCacheProvider cacheProvider) { this.loginService = loginService; this.cacheProvider = cacheProvider; }
public HomeController(IConfiguration configuration, IDisctributedCacheProvider cacheProvider) { this.configuration = configuration; this.cacheProvider = cacheProvider; }