public AccountController( UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, IEmailSender emailSender, ILoggerFactory loggerFactory, IConfiguration config, IHttpContextAccessor contextAccessor, ICachedUserRepository <ApplicationUser> userRepository, IMemoryCache cache) { _userManager = userManager; _signInManager = signInManager; _emailSender = emailSender; _logger = loggerFactory.CreateLogger("AccountController"); _config = config; _httpContext = contextAccessor.HttpContext; _userRepository = userRepository; _userContext = new UserContext(_userRepository, _userManager, contextAccessor, _config, loggerFactory, cache); }
public UserContext(ICachedUserRepository <ApplicationUser> userRepository, UserManager <ApplicationUser> userManager, IHttpContextAccessor contextAccessor, IConfiguration config, ILoggerFactory loggerFactory, IMemoryCache cache) { _userRepository = userRepository; _userManager = userManager; _httpContext = contextAccessor.HttpContext; _config = config; _logger = loggerFactory.CreateLogger("UserContext"); _cache = cache; // 5 second cache cacheOptions = new MemoryCacheEntryOptions() .SetAbsoluteExpiration(relative: TimeSpan.FromSeconds(DEFAULT_CACHE_SECONDS)); }