Пример #1
0
 public LoginController(SimpleForumRepository repository, CrossConnectionManager crossConnectionManager,
                        IOptionsSnapshot <SimpleForumConfig> config)
 {
     _repository             = repository;
     _crossConnectionManager = crossConnectionManager;
     _config = config.Value;
 }
Пример #2
0
 public AuthenticationHandler(
     IOptionsMonitor <AuthenticationOptions> options,
     ILoggerFactory logger,
     UrlEncoder encoder,
     ISystemClock clock,
     SimpleForumRepository repository)
     : base(options, logger, encoder, clock)
 {
     _repository = repository;
 }
Пример #3
0
        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);
        }
Пример #4
0
        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;
 }
Пример #6
0
 public ThreadsController(SimpleForumRepository repository)
 {
     _repository = repository;
 }
Пример #7
0
 public UserCommentsController(SimpleForumRepository repository)
 {
     _repository = repository;
 }
Пример #8
0
 public AuthController(SimpleForumRepository repository, CrossConnectionClient crossConnectionClient)
 {
     _repository            = repository;
     _crossConnectionClient = crossConnectionClient;
 }
 public NotificationsController(SimpleForumRepository repository)
 {
     _repository = repository;
 }
Пример #10
0
 public PreventMuted(SimpleForumRepository repository)
 {
     _repository = repository;
 }
Пример #11
0
 public HomeController(SimpleForumRepository repository, ApplicationDbContext context, IOptionsSnapshot <SimpleForumConfig> config)
 {
     _repository = repository;
     _context    = context;
     _config     = config.Value;
 }
Пример #12
0
 public AuthController(IAuthenticationManager manager, SimpleForumRepository repository)
 {
     _manager    = manager;
     _repository = repository;
 }