From 7457cbbf0e415d875837b98aa116797e270974ce Mon Sep 17 00:00:00 2001 From: jojo aquino Date: Sun, 15 Dec 2024 10:55:54 +0000 Subject: [PATCH] add PrincipalPolicy --- EnotaryoPH/EnotaryoPH.Web/Program.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/EnotaryoPH/EnotaryoPH.Web/Program.cs b/EnotaryoPH/EnotaryoPH.Web/Program.cs index 4cfc6e0..9d4cd94 100644 --- a/EnotaryoPH/EnotaryoPH.Web/Program.cs +++ b/EnotaryoPH/EnotaryoPH.Web/Program.cs @@ -14,7 +14,8 @@ namespace EnotaryoPH.Web builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options => options.LoginPath = new Microsoft.AspNetCore.Http.PathString("/Login")); - builder.Services.AddRazorPages(); + builder.Services.AddAuthorization(options => options.AddPolicy("PrincipalPolicy", policy => policy.RequireRole("Principal"))); + builder.Services.AddRazorPages(options => options.Conventions.AuthorizeFolder("/Principal", "PrincipalPolicy")); builder.Services.AddDbContext(); builder.Services.AddTransient(); builder.Services.AddHttpContextAccessor();