diff --git a/HerramientaCASA/Components/Layout/ConfiguracionLayout.razor b/HerramientaCASA/Components/Layout/ConfiguracionLayout.razor index 42f156d..92daba3 100644 --- a/HerramientaCASA/Components/Layout/ConfiguracionLayout.razor +++ b/HerramientaCASA/Components/Layout/ConfiguracionLayout.razor @@ -4,7 +4,8 @@ @using Microsoft.AspNetCore.Components.Web @inject NavigationManager Navigation @using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage -@inject ProtectedSessionStorage ProtectedSessionStore +@inject ProtectedLocalStorage ProtectedLocalStore + @@ -97,8 +98,8 @@ protected override async Task OnInitializedAsync() { - var obtenerDatoAdmin = await ProtectedSessionStore.GetAsync("EsAdmin"); - var obtenerDatoId = await ProtectedSessionStore.GetAsync("idUsuario"); + var obtenerDatoAdmin = await ProtectedLocalStore.GetAsync("EsAdmin"); + var obtenerDatoId = await ProtectedLocalStore.GetAsync("idUsuario"); // Redirigir al home si no hay token y la ruta no es pública if (obtenerDatoId.Value == 0 || !obtenerDatoAdmin.Value) { diff --git a/HerramientaCASA/Components/Layout/MainLayout.razor b/HerramientaCASA/Components/Layout/MainLayout.razor index d450360..ac383eb 100644 --- a/HerramientaCASA/Components/Layout/MainLayout.razor +++ b/HerramientaCASA/Components/Layout/MainLayout.razor @@ -4,7 +4,8 @@ @inherits LayoutComponentBase @inject NavigationManager Navigation @using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage -@inject ProtectedSessionStorage ProtectedSessionStore +@inject ProtectedLocalStorage ProtectedLocalStore + @@ -102,8 +103,8 @@ protected override async Task OnInitializedAsync() { - var obtenerDatoAdmin = await ProtectedSessionStore.GetAsync("EsAdmin"); - var obtenerDatoId = await ProtectedSessionStore.GetAsync("idUsuario"); + var obtenerDatoAdmin = await ProtectedLocalStore.GetAsync("EsAdmin"); + var obtenerDatoId = await ProtectedLocalStore.GetAsync("idUsuario"); // Redirigir al home si no hay token y la ruta no es pública if (obtenerDatoId.Value == 0 || obtenerDatoAdmin.Value) { diff --git a/HerramientaCASA/Components/Pages/Comun/ClonarDespacho.razor b/HerramientaCASA/Components/Pages/Comun/ClonarDespacho.razor index f75784c..c93442c 100644 --- a/HerramientaCASA/Components/Pages/Comun/ClonarDespacho.razor +++ b/HerramientaCASA/Components/Pages/Comun/ClonarDespacho.razor @@ -5,7 +5,8 @@ @using bdHerramientaCACOA.HerramientaURBAN @using bdHerramientaCACOA.db @using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage -@inject ProtectedSessionStorage ProtectedSessionStore +@inject ProtectedLocalStorage ProtectedLocalStore + @inject NavigationManager Navigation @inject UserState UserState @@ -80,7 +81,7 @@ private async void cargarListaSimulaciones() { - var idUser = await ProtectedSessionStore.GetAsync("idUsuario"); + var idUser = await ProtectedLocalStore.GetAsync("idUsuario"); listadoSimulaciones = bd.simulaciones.Include(x => x.idTipoSimulacionNavigation).Where(x => x.idCodigo == idUser.Value && (x.idTipoSimulacionNavigation.Codigo == "TIPOHERRAMIENTA.CASA" || x.idTipoSimulacionNavigation.Codigo == "TIPOHERRAMIENTA.URBAND") && x.idSimulacion != datosDespachoClonado.idSimulacion).ToList(); diff --git a/HerramientaCASA/Components/Pages/HerramientaCASAS.razor b/HerramientaCASA/Components/Pages/HerramientaCASAS.razor index e0b2d14..08c6873 100644 --- a/HerramientaCASA/Components/Pages/HerramientaCASAS.razor +++ b/HerramientaCASA/Components/Pages/HerramientaCASAS.razor @@ -6,7 +6,8 @@ @using bdHerramientaCACOA.db @using Newtonsoft.Json @using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage -@inject ProtectedSessionStorage ProtectedSessionStore +@inject ProtectedLocalStorage ProtectedLocalStore + @rendermode InteractiveServer @inject NavigationManager Navigation @@ -166,7 +167,7 @@ nombreOriginal = casa.NombreSimulacion; } - var obtenerID = await ProtectedSessionStore.GetAsync("idUsuario"); + var obtenerID = await ProtectedLocalStore.GetAsync("idUsuario"); idUser = obtenerID.Value; } catch (Exception ex) diff --git a/HerramientaCASA/Components/Pages/HerramientaURBAN.razor b/HerramientaCASA/Components/Pages/HerramientaURBAN.razor index 512bea6..63f4217 100644 --- a/HerramientaCASA/Components/Pages/HerramientaURBAN.razor +++ b/HerramientaCASA/Components/Pages/HerramientaURBAN.razor @@ -7,7 +7,8 @@ @using bdHerramientaCACOA.HerramientaURBAN @using bdHerramientaCACOA.db @using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage -@inject ProtectedSessionStorage ProtectedSessionStore +@inject ProtectedLocalStorage ProtectedLocalStore + @rendermode InteractiveServer @inject NavigationManager Navigation @@ -145,7 +146,7 @@ } - var obtenerID = await ProtectedSessionStore.GetAsync("idUsuario"); + var obtenerID = await ProtectedLocalStore.GetAsync("idUsuario"); idUser = obtenerID.Value; } catch (Exception ex) diff --git a/HerramientaCASA/Components/Pages/Licitaciones.razor b/HerramientaCASA/Components/Pages/Licitaciones.razor index faeeaa2..055213c 100644 --- a/HerramientaCASA/Components/Pages/Licitaciones.razor +++ b/HerramientaCASA/Components/Pages/Licitaciones.razor @@ -5,7 +5,8 @@ @using bdHerramientaCACOA.db @using HerramientaCASA.Components.Pages.LicitacionesGrids @using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage -@inject ProtectedSessionStorage ProtectedSessionStore +@inject ProtectedLocalStorage ProtectedLocalStore + @page "/LicitacionCASA" @page "/LicitacionCASA/{idSimulador}" @@ -264,7 +265,7 @@ nombreOriginal = objetoLicitaciones.Descripcion; } - var obtenerID = await ProtectedSessionStore.GetAsync("idUsuario"); + var obtenerID = await ProtectedLocalStore.GetAsync("idUsuario"); idUser = obtenerID.Value; } catch (Exception ex) diff --git a/HerramientaCASA/Components/Pages/LicitacionesURBAN.razor b/HerramientaCASA/Components/Pages/LicitacionesURBAN.razor index 4759951..417e4ad 100644 --- a/HerramientaCASA/Components/Pages/LicitacionesURBAN.razor +++ b/HerramientaCASA/Components/Pages/LicitacionesURBAN.razor @@ -8,7 +8,8 @@ @using bdHerramientaCACOA.HerramientaURBAN @using bdHerramientaCACOA.db @using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage -@inject ProtectedSessionStorage ProtectedSessionStore +@inject ProtectedLocalStorage ProtectedLocalStore + @inject NavigationManager Navigation @@ -272,7 +273,7 @@ } - var obtenerID = await ProtectedSessionStore.GetAsync("idUsuario"); + var obtenerID = await ProtectedLocalStore.GetAsync("idUsuario"); idUser = obtenerID.Value; } catch (Exception ex) diff --git a/HerramientaCASA/Components/Pages/Login/ClaveGenerada.razor b/HerramientaCASA/Components/Pages/Login/ClaveGenerada.razor index 4654352..e0179cd 100644 --- a/HerramientaCASA/Components/Pages/Login/ClaveGenerada.razor +++ b/HerramientaCASA/Components/Pages/Login/ClaveGenerada.razor @@ -6,7 +6,7 @@ @rendermode InteractiveServer @layout LoginLayout @inject NavigationManager Navigation -@inject ProtectedSessionStorage ProtectedSessionStore +@inject ProtectedLocalStorage ProtectedLocalStore
@@ -32,7 +32,7 @@ { bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false); - var obtenerId = await ProtectedSessionStore.GetAsync("idUsuario"); + var obtenerId = await ProtectedLocalStore.GetAsync("idUsuario"); claveUsuario = obtenerId.Value; if (claveUsuario == 0 || claveUsuario == null) diff --git a/HerramientaCASA/Components/Pages/Login/Login.razor b/HerramientaCASA/Components/Pages/Login/Login.razor index 4466192..3760ef8 100644 --- a/HerramientaCASA/Components/Pages/Login/Login.razor +++ b/HerramientaCASA/Components/Pages/Login/Login.razor @@ -1,7 +1,7 @@ @page "/" @using HerramientaCASA.Model @using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage -@inject ProtectedSessionStorage ProtectedSessionStore +@inject ProtectedLocalStorage ProtectedLocalStore @rendermode InteractiveServer @layout LoginLayout @inject IHttpContextAccessor HttpContextAccessor @@ -59,8 +59,8 @@ { bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false); - await ProtectedSessionStore.SetAsync("idUsuario", 0); - await ProtectedSessionStore.SetAsync("EsAdmin", false); + await ProtectedLocalStore.SetAsync("idUsuario", 0); + await ProtectedLocalStore.SetAsync("EsAdmin", false); // Limpiar almacenamiento local o sesión si se está utilizando // if (HttpContextAccessor?.HttpContext?.Session != null) @@ -74,8 +74,8 @@ //if (login.codigo == -534610 && login.password == "sRg1406.") if (login.codigo == -1 && login.password == "-1") { - await ProtectedSessionStore.SetAsync("idUsuario", -1); - await ProtectedSessionStore.SetAsync("EsAdmin", true); + await ProtectedLocalStore.SetAsync("idUsuario", -1); + await ProtectedLocalStore.SetAsync("EsAdmin", true); Navigation.NavigateTo("/PanelControlConf", forceLoad: true); } @@ -90,8 +90,8 @@ else { - await ProtectedSessionStore.SetAsync("idUsuario", usuario.idUsuario); - await ProtectedSessionStore.SetAsync("EsAdmin", false); + await ProtectedLocalStore.SetAsync("idUsuario", usuario.idUsuario); + await ProtectedLocalStore.SetAsync("EsAdmin", false); Navigation.NavigateTo("/PanelControl", forceLoad: true); diff --git a/HerramientaCASA/Components/Pages/Login/NuevoAcceso.razor b/HerramientaCASA/Components/Pages/Login/NuevoAcceso.razor index c81d591..1511488 100644 --- a/HerramientaCASA/Components/Pages/Login/NuevoAcceso.razor +++ b/HerramientaCASA/Components/Pages/Login/NuevoAcceso.razor @@ -6,7 +6,7 @@ @rendermode InteractiveServer @layout LoginLayout @inject NavigationManager Navigation -@inject ProtectedSessionStorage ProtectedSessionStore +@inject ProtectedLocalStorage ProtectedLocalStore
@@ -61,7 +61,7 @@ nuevoAcceso.Codigo = nuevoAcceso.idUsuario; bd.SaveChanges(); - await ProtectedSessionStore.SetAsync("idUsuario", nuevoAcceso.idUsuario); + await ProtectedLocalStore.SetAsync("idUsuario", nuevoAcceso.idUsuario); Navigation.NavigateTo("/ClaveGenerada", forceLoad: true); diff --git a/HerramientaCASA/Components/Pages/Simulaciones/SimulacionesTabs.razor b/HerramientaCASA/Components/Pages/Simulaciones/SimulacionesTabs.razor index a381774..4606937 100644 --- a/HerramientaCASA/Components/Pages/Simulaciones/SimulacionesTabs.razor +++ b/HerramientaCASA/Components/Pages/Simulaciones/SimulacionesTabs.razor @@ -2,7 +2,7 @@ @using Microsoft.EntityFrameworkCore @using bdHerramientaCACOA.db @using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage -@inject ProtectedSessionStorage ProtectedSessionStore +@inject ProtectedLocalStorage ProtectedLocalStore @inject UserState UserState @@ -71,7 +71,7 @@ { bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: true); - var obtenerID = await ProtectedSessionStore.GetAsync("idUsuario"); + var obtenerID = await ProtectedLocalStore.GetAsync("idUsuario"); idUser = obtenerID.Value; listadoSimulaciones = bd.simulaciones.Include(x => x.idTipoSimulacionNavigation).Include(x => x.idFicheroJSONNavigation).Where(x => x.idCodigo == idUser && x.idTipoSimulacionNavigation.Codigo == "TIPOHERRAMIENTA." + TipoSimulacion).ToList(); diff --git a/HerramientaCASA/Program.cs b/HerramientaCASA/Program.cs index 223b2fe..af047e1 100644 --- a/HerramientaCASA/Program.cs +++ b/HerramientaCASA/Program.cs @@ -39,7 +39,7 @@ builder.Services.AddSession(options => builder.Services.AddBlazorBootstrap(); builder.Services.AddAntiforgery(); builder.Services.AddSingleton(); -builder.Services.AddScoped(); +builder.Services.AddScoped(); var app = builder.Build();