From ddfe6289778f2ec1f29140239d2129647af81a4d Mon Sep 17 00:00:00 2001 From: Perea Date: Wed, 24 Sep 2025 14:50:55 +0200 Subject: [PATCH] agregado comprobar url cacoa (segurametne haya que cambiarlo) --- .../Layout/ConfiguracionLayout.razor | 20 ++++++++++++ .../Components/Layout/LoginLayout.razor | 21 ++++++++++++ .../Components/Layout/MainLayout.razor | 20 ++++++++++++ .../Components/Pages/Login/Denegado.razor | 32 +++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 HerramientaCASA/Components/Pages/Login/Denegado.razor diff --git a/HerramientaCASA/Components/Layout/ConfiguracionLayout.razor b/HerramientaCASA/Components/Layout/ConfiguracionLayout.razor index 6f3bed6..8e2a68b 100644 --- a/HerramientaCASA/Components/Layout/ConfiguracionLayout.razor +++ b/HerramientaCASA/Components/Layout/ConfiguracionLayout.razor @@ -2,6 +2,7 @@ @using BlazorBootstrap; @using HerramientaCASA.Model @using Microsoft.AspNetCore.Components.Web +@inject IHttpContextAccessor HttpContextAccessor @inject NavigationManager Navigation @using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage @inject ProtectedLocalStorage ProtectedLocalStore @@ -115,4 +116,23 @@ Navigation.NavigateTo("/", true); } } + + + protected override void OnAfterRender(bool firstRender) + { + if (firstRender) + { + string? urlAnterior = HttpContextAccessor.HttpContext?.Request.Headers["Referer"].ToString(); + string rutaActual = Navigation.ToBaseRelativePath(Navigation.Uri); + + if (rutaActual != "Denegado") + { + if (string.IsNullOrEmpty(urlAnterior) || urlAnterior.Contains("cacoa.es")) + { + Navigation.NavigateTo("/Denegado", true); + } + } + } + } +} } diff --git a/HerramientaCASA/Components/Layout/LoginLayout.razor b/HerramientaCASA/Components/Layout/LoginLayout.razor index 2d64e60..690c132 100644 --- a/HerramientaCASA/Components/Layout/LoginLayout.razor +++ b/HerramientaCASA/Components/Layout/LoginLayout.razor @@ -3,6 +3,8 @@ @using HerramientaCASA.Model @using Microsoft.AspNetCore.Components.Web @inject UserState UserState +@inject IHttpContextAccessor HttpContextAccessor +@inject NavigationManager Navigation @@ -37,4 +39,23 @@ @code{ + protected override void OnAfterRender(bool firstRender) + { + if (firstRender) + { + string? urlAnterior = HttpContextAccessor.HttpContext?.Request.Headers["Referer"].ToString(); + string rutaActual = Navigation.ToBaseRelativePath(Navigation.Uri); + + if (rutaActual != "Denegado") + { + if (string.IsNullOrEmpty(urlAnterior) || urlAnterior.Contains("cacoa.es")) + { + Navigation.NavigateTo("/Denegado", true); + } + } + } + } + } + + } \ No newline at end of file diff --git a/HerramientaCASA/Components/Layout/MainLayout.razor b/HerramientaCASA/Components/Layout/MainLayout.razor index 2a97131..440b273 100644 --- a/HerramientaCASA/Components/Layout/MainLayout.razor +++ b/HerramientaCASA/Components/Layout/MainLayout.razor @@ -2,6 +2,7 @@ @using HerramientaCASA.Model @using Microsoft.AspNetCore.Components.Web @inherits LayoutComponentBase +@inject IHttpContextAccessor HttpContextAccessor @inject NavigationManager Navigation @using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage @inject ProtectedLocalStorage ProtectedLocalStore @@ -121,4 +122,23 @@ ? "nav-link headNav active" : "nav-link headNav"; } + + + protected override void OnAfterRender(bool firstRender) + { + if (firstRender) + { + string? urlAnterior = HttpContextAccessor.HttpContext?.Request.Headers["Referer"].ToString(); + string rutaActual = Navigation.ToBaseRelativePath(Navigation.Uri); + + if (rutaActual != "Denegado") + { + if (string.IsNullOrEmpty(urlAnterior) || urlAnterior.Contains("cacoa.es")) + { + Navigation.NavigateTo("/Denegado", true); + } + } + } + } +} } diff --git a/HerramientaCASA/Components/Pages/Login/Denegado.razor b/HerramientaCASA/Components/Pages/Login/Denegado.razor new file mode 100644 index 0000000..e9fbd0c --- /dev/null +++ b/HerramientaCASA/Components/Pages/Login/Denegado.razor @@ -0,0 +1,32 @@ +@page "/Denegado" +@using HerramientaCASA.Model +@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage +@inject ProtectedLocalStorage ProtectedLocalStore +@rendermode InteractiveServer +@layout LoginLayout +@inject IHttpContextAccessor HttpContextAccessor +@inject NavigationManager Navigation +@inject UserState UserState + + +
+
+
+
+ +

Acceso Denegado

+
+
+

+ Se ha agotado la sesión o se ha accedido a la aplicación desde fuera de la Web del CACOA.
+ Por favor vuelva a acceder desde la web +

+
+ Ir a la web del CACOA +
+
+
+
+ +@code { +}