Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public LoginController(LoginService loginService,
                        IDisctributedCacheProvider cacheProvider)
 {
     this.loginService  = loginService;
     this.cacheProvider = cacheProvider;
 }
Exemplo n.º 3
0
 public HomeController(IConfiguration configuration,
                       IDisctributedCacheProvider cacheProvider)
 {
     this.configuration = configuration;
     this.cacheProvider = cacheProvider;
 }