From 58ef5833b3f77f321c587dd86448c888029016ce Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Thu, 22 Dec 2022 14:44:26 +0100 Subject: feat: Many things - Working Login/Logout - Groundwork for web components - Loading web-components with version tag - Load temporal-polyfill globally --- code/api/Pages/BasePageModel.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 code/api/Pages/BasePageModel.cs (limited to 'code/api/Pages/BasePageModel.cs') diff --git a/code/api/Pages/BasePageModel.cs b/code/api/Pages/BasePageModel.cs new file mode 100644 index 0000000..7858dc4 --- /dev/null +++ b/code/api/Pages/BasePageModel.cs @@ -0,0 +1,17 @@ +using Microsoft.AspNetCore.Mvc.Filters; + +namespace I2R.Storage.Api.Pages; + +public class BasePageModel : PageModel +{ + public LoggedInUserModel LoggedInUser => new(User); + public bool IsAutenticated => User.Identity?.IsAuthenticated ?? false; + + public override void OnPageHandlerExecuting(PageHandlerExecutingContext context) { + if (!context.HttpContext.User.Identity?.IsAuthenticated ?? true) { + context.Result = new RedirectResult("/login"); + } + + base.OnPageHandlerExecuting(context); + } +} \ No newline at end of file -- cgit v1.3