void IPageFilter.OnPageHandlerExecuting(PageHandlerExecutingContext context)
        {
            var cookie = cookieStorage.ReadAdmin(context.HttpContext.Request);

            cookie.Match(some =>
            {
                if (!adminSettings.IsValid(some).HasValue)
                {
                    context.Result = new ForbidResult();
                }
            }, () => context.Result = new ForbidResult());
        }
Exemple #2
0
        public IActionResult OnGet()
        {
            IActionResult Func() => Page().ToIAR();

            var authCookie = cookieStorage.ReadAdmin(this.HttpContext.Request);

            return(authCookie.Match(some =>
            {
                var res = adminSettings.IsValid(some);
                return res.Match(_ => this.RedirectToPage <AdminModel>().ToIAR(), Func);
            }, Func));
        }
Exemple #3
0
        bool IIsAdmin.IsAdmin(HttpContext httpContext)
        {
            var cookie = cookieStorage.ReadAdmin(httpContext.Request);

            return(cookie.Match(some =>
            {
                if (!adminSettings.IsValid(some).HasValue)
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }, () => false));
        }
Exemple #4
0
        public Task <IActionResult> OnGet(CancellationToken cancellationToken)
        {
            Task <IActionResult> Func() => this.RedirectToPage <LoginModel>().ToIART();

            var authCookie = cookieStorage.ReadAdmin(this.HttpContext.Request);

            return(authCookie.Match(some =>
            {
                var res = adminSettings.IsValid(some);
                return res.Match(async _ =>
                {
                    var boards = await this.boardService.GetAll(cancellationToken);
                    var bannedImages = await this.fileService.GetAllBannedImages(cancellationToken);
                    var banns = await this.userService.GetAllBans(cancellationToken);

                    this.Model = new AdminViewModel(bannedImages, banns, boards);
                    return Page().ToIAR();
                }, Func);
            }, Func));
        }