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()); }
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)); }
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)); }
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)); }