From efecf55dd882a6b5171b6174c01f4269a91c5628 Mon Sep 17 00:00:00 2001 From: ivanszabo Date: Fri, 21 Mar 2025 09:57:07 +0100 Subject: [PATCH] =?UTF-8?q?Middleware=20jav=C3=ADt=C3=A1s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/WorkFlowCheck.Web/Middleware/JwtMiddleware.cs | 7 +++++++ src/WorkFlowCheck.Web/Pages/Account/Login.cshtml.cs | 2 ++ .../CheckListTemplateRowEditPage.cshtml | 11 ++++++----- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/WorkFlowCheck.Web/Middleware/JwtMiddleware.cs b/src/WorkFlowCheck.Web/Middleware/JwtMiddleware.cs index 29eff5e..18a4dbc 100644 --- a/src/WorkFlowCheck.Web/Middleware/JwtMiddleware.cs +++ b/src/WorkFlowCheck.Web/Middleware/JwtMiddleware.cs @@ -32,6 +32,13 @@ namespace WorkFlowCheck.Web.Middleware { context.Response.Cookies.Delete("AuthToken"); } + var path = context.Request.Path.ToString().ToLower(); + + if (!path.StartsWith("/account/login") && !path.StartsWith("/account/register")) + { + context.Response.Redirect("/Account/Login"); + return; + } } await _next(context); } diff --git a/src/WorkFlowCheck.Web/Pages/Account/Login.cshtml.cs b/src/WorkFlowCheck.Web/Pages/Account/Login.cshtml.cs index c9b3cb1..d11e412 100644 --- a/src/WorkFlowCheck.Web/Pages/Account/Login.cshtml.cs +++ b/src/WorkFlowCheck.Web/Pages/Account/Login.cshtml.cs @@ -1,3 +1,4 @@ +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity.Data; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; @@ -7,6 +8,7 @@ using WorkFlowCheck.Web.Services.Interfaces; namespace WorkFlowCheck.Web.Pages.Account { + [AllowAnonymous] public class LoginModel : PageModel { diff --git a/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateRows/CheckListTemplateRowEditPage.cshtml b/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateRows/CheckListTemplateRowEditPage.cshtml index d6cc627..bab43e4 100644 --- a/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateRows/CheckListTemplateRowEditPage.cshtml +++ b/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateRows/CheckListTemplateRowEditPage.cshtml @@ -72,11 +72,12 @@ }, data: JSON.stringify(formData.CheckListTemplateRow), success: function (response) { - showMessageModal({ - title: 'Figyelmem!', - message: 'Sikeres mentés.', - okText: 'Értettem' - }); + // showMessageModal({ + // title: 'Figyelmem!', + // message: 'Sikeres mentés.', + // okText: 'Értettem' + // }); + history.back(); }, error: function (xhr, status, error) { // Hiba esetén