public LoginController(SimpleForumRepository repository, CrossConnectionManager crossConnectionManager, IOptionsSnapshot <SimpleForumConfig> config) { _repository = repository; _crossConnectionManager = crossConnectionManager; _config = config.Value; }
public AuthenticationHandler( IOptionsMonitor <AuthenticationOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock, SimpleForumRepository repository) : base(options, logger, encoder, clock) { _repository = repository; }
public async Task InvokeAsync(HttpContext httpContext, SimpleForumRepository repository) { // Urls which can be accessed whilst an account is banned List <string> urlExceptions = new List <string>() { "/Error/Banned", "/Login/Logout", "/Error/StatusError" }; List <bool> conditions = new List <bool>() { httpContext.User.Identity.IsAuthenticated, urlExceptions.All(x => x != httpContext.Request.Path.Value) }; if (conditions.All(x => x)) { User user = await repository.GetUserAsync(httpContext.User); if (user == null) { await httpContext.SignOutAsync(); } else if (user.Deleted) { await httpContext.SignOutAsync(); } else if (user.Banned) { httpContext.Response.Redirect("/Error/Banned"); } } await _next(httpContext); }
public RepositoryTest() { // Creates ApplicationDbContext from in memory database DbContextOptions <ApplicationDbContext> options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseSqlite(CreateInMemory()).Options; _connection = RelationalOptionsExtension.Extract(options).Connection; ApplicationDbContext context = new ApplicationDbContext(options); context.Database.EnsureCreated(); // Creates repository and adds data repository = new SimpleForumRepository(context, null, null, null); repository.AddUserAsync(new User() { Username = "******", Password = "******", Email = "*****@*****.**" }).Wait(); repository.SaveChangesAsync().Wait(); repository.AddThreadAsync(new Thread() { Title = "first thread", Content = "Thread content", UserID = 1 }).Wait(); repository.SaveChangesAsync().Wait(); }
public AuthenticationManager(SimpleForumRepository repository, IOptionsSnapshot <SimpleForumConfig> config) { _repository = repository; _config = config.Value; }
public ThreadsController(SimpleForumRepository repository) { _repository = repository; }
public UserCommentsController(SimpleForumRepository repository) { _repository = repository; }
public AuthController(SimpleForumRepository repository, CrossConnectionClient crossConnectionClient) { _repository = repository; _crossConnectionClient = crossConnectionClient; }
public NotificationsController(SimpleForumRepository repository) { _repository = repository; }
public PreventMuted(SimpleForumRepository repository) { _repository = repository; }
public HomeController(SimpleForumRepository repository, ApplicationDbContext context, IOptionsSnapshot <SimpleForumConfig> config) { _repository = repository; _context = context; _config = config.Value; }
public AuthController(IAuthenticationManager manager, SimpleForumRepository repository) { _manager = manager; _repository = repository; }