public JwtService( IOptions <JwtConfig> jwtConfig, IJwtSessionService jwtSessionService, ILogger <IJwtService> logger ) { this.JwtConfig = jwtConfig.Value; this.JwtSessionService = jwtSessionService; this.Logger = logger; }
public async Task InvokeAsync(HttpContext context, CurrentLoginInfo currentLoginInfo, IJwtSessionService jwtSessionService) { var session = currentLoginInfo.Session ?? string.Empty; if (!string.IsNullOrWhiteSpace(session) && !jwtSessionService.ContainsKey(session)) { context.Response.Clear(); context.Response.StatusCode = StatusCodes.Status401Unauthorized; } else { await Next(context); } }