Merge branch 'master' of https://gitea.tecnosis.net/CACOA/HerramientaCASA
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@inject NavigationManager Navigation
|
||||
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
|
||||
@inject ProtectedSessionStorage ProtectedSessionStore
|
||||
@inject ProtectedLocalStorage ProtectedLocalStore
|
||||
|
||||
|
||||
<head>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
||||
@@ -97,8 +98,8 @@
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var obtenerDatoAdmin = await ProtectedSessionStore.GetAsync<bool>("EsAdmin");
|
||||
var obtenerDatoId = await ProtectedSessionStore.GetAsync<int>("idUsuario");
|
||||
var obtenerDatoAdmin = await ProtectedLocalStore.GetAsync<bool>("EsAdmin");
|
||||
var obtenerDatoId = await ProtectedLocalStore.GetAsync<int>("idUsuario");
|
||||
// Redirigir al home si no hay token y la ruta no es pública
|
||||
if (obtenerDatoId.Value == 0 || !obtenerDatoAdmin.Value)
|
||||
{
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
@inherits LayoutComponentBase
|
||||
@inject NavigationManager Navigation
|
||||
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
|
||||
@inject ProtectedSessionStorage ProtectedSessionStore
|
||||
@inject ProtectedLocalStorage ProtectedLocalStore
|
||||
|
||||
|
||||
<head>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
||||
@@ -102,8 +103,8 @@
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var obtenerDatoAdmin = await ProtectedSessionStore.GetAsync<bool>("EsAdmin");
|
||||
var obtenerDatoId = await ProtectedSessionStore.GetAsync<int>("idUsuario");
|
||||
var obtenerDatoAdmin = await ProtectedLocalStore.GetAsync<bool>("EsAdmin");
|
||||
var obtenerDatoId = await ProtectedLocalStore.GetAsync<int>("idUsuario");
|
||||
// Redirigir al home si no hay token y la ruta no es pública
|
||||
if (obtenerDatoId.Value == 0 || obtenerDatoAdmin.Value)
|
||||
{
|
||||
|
||||
@@ -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<int>("idUsuario");
|
||||
var idUser = await ProtectedLocalStore.GetAsync<int>("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();
|
||||
|
||||
|
||||
@@ -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<int>("idUsuario");
|
||||
var obtenerID = await ProtectedLocalStore.GetAsync<int>("idUsuario");
|
||||
idUser = obtenerID.Value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -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<int>("idUsuario");
|
||||
var obtenerID = await ProtectedLocalStore.GetAsync<int>("idUsuario");
|
||||
idUser = obtenerID.Value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -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<int>("idUsuario");
|
||||
var obtenerID = await ProtectedLocalStore.GetAsync<int>("idUsuario");
|
||||
idUser = obtenerID.Value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -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
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
@@ -272,7 +273,7 @@
|
||||
|
||||
}
|
||||
|
||||
var obtenerID = await ProtectedSessionStore.GetAsync<int>("idUsuario");
|
||||
var obtenerID = await ProtectedLocalStore.GetAsync<int>("idUsuario");
|
||||
idUser = obtenerID.Value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
@rendermode InteractiveServer
|
||||
@layout LoginLayout
|
||||
@inject NavigationManager Navigation
|
||||
@inject ProtectedSessionStorage ProtectedSessionStore
|
||||
@inject ProtectedLocalStorage ProtectedLocalStore
|
||||
|
||||
|
||||
<div class="back">
|
||||
@@ -32,7 +32,7 @@
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
|
||||
var obtenerId = await ProtectedSessionStore.GetAsync<int>("idUsuario");
|
||||
var obtenerId = await ProtectedLocalStore.GetAsync<int>("idUsuario");
|
||||
claveUsuario = obtenerId.Value;
|
||||
|
||||
if (claveUsuario == 0 || claveUsuario == null)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
@rendermode InteractiveServer
|
||||
@layout LoginLayout
|
||||
@inject NavigationManager Navigation
|
||||
@inject ProtectedSessionStorage ProtectedSessionStore
|
||||
@inject ProtectedLocalStorage ProtectedLocalStore
|
||||
|
||||
|
||||
<div class="back">
|
||||
@@ -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);
|
||||
|
||||
@@ -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<int>("idUsuario");
|
||||
var obtenerID = await ProtectedLocalStore.GetAsync<int>("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();
|
||||
|
||||
@@ -39,7 +39,7 @@ builder.Services.AddSession(options =>
|
||||
builder.Services.AddBlazorBootstrap();
|
||||
builder.Services.AddAntiforgery();
|
||||
builder.Services.AddSingleton<UserState>();
|
||||
builder.Services.AddScoped<ProtectedSessionStorage>();
|
||||
builder.Services.AddScoped<ProtectedLocalStorage>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user