Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 49b232eaa8 | |||
| 3faecbb639 |
@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using NexusReader.Domain.Entities;
|
||||
using NexusReader.Infrastructure.Persistence;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NexusReader.Infrastructure.Identity;
|
||||
|
||||
@@ -11,12 +12,12 @@ namespace NexusReader.Infrastructure.Identity;
|
||||
/// </summary>
|
||||
public class TokenLimitHandler : AuthorizationHandler<TokenLimitRequirement>
|
||||
{
|
||||
private readonly AppDbContext _dbContext;
|
||||
private readonly IDbContextFactory<AppDbContext> _dbContextFactory;
|
||||
private readonly UserManager<NexusUser> _userManager;
|
||||
|
||||
public TokenLimitHandler(AppDbContext dbContext, UserManager<NexusUser> userManager)
|
||||
public TokenLimitHandler(IDbContextFactory<AppDbContext> dbContextFactory, UserManager<NexusUser> userManager)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_dbContextFactory = dbContextFactory;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,8 @@ using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var services = scope.ServiceProvider;
|
||||
var logger = services.GetRequiredService<ILogger<Program>>();
|
||||
var dbContext = services.GetRequiredService<NexusReader.Infrastructure.Persistence.AppDbContext>();
|
||||
var dbContextFactory = services.GetRequiredService<IDbContextFactory<NexusReader.Infrastructure.Persistence.AppDbContext>>();
|
||||
using var dbContext = await dbContextFactory.CreateDbContextAsync();
|
||||
|
||||
int maxRetries = 5;
|
||||
int delayMs = 2000;
|
||||
|
||||
Reference in New Issue
Block a user