コード例 #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);
        }
コード例 #2
0
 public LoginController(LoginService loginService,
                        IDisctributedCacheProvider cacheProvider)
 {
     this.loginService  = loginService;
     this.cacheProvider = cacheProvider;
 }
コード例 #3
0
 public HomeController(IConfiguration configuration,
                       IDisctributedCacheProvider cacheProvider)
 {
     this.configuration = configuration;
     this.cacheProvider = cacheProvider;
 }