Metodos firma sobre AdminUsuarios
This commit is contained in:
parent
3c4a9e23d1
commit
719616920e
@ -26,12 +26,18 @@ namespace ApiGateway
|
||||
//var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole().AddEventLog());
|
||||
//var logger = loggerFactory.CreateLogger("Auth");
|
||||
|
||||
//TODO: ELIMINAR ESTAS RUTAS POR COMPLETO!
|
||||
// TknCambioClave
|
||||
// Desencriptar - encriptar
|
||||
|
||||
|
||||
string calledUrl = ctx.Items.DownstreamRoute().UpstreamPathTemplate.OriginalValue;
|
||||
|
||||
// Excepcion para login, no requiere token
|
||||
if (String.Equals(calledUrl, "/Ext/Login") ||
|
||||
String.Equals(calledUrl, "/Auth/Login") ||
|
||||
String.Equals(calledUrl, "/Auth/CambiarClave") ||
|
||||
String.Equals(calledUrl, "/Auth/TknCambioClave") ||
|
||||
String.Equals(calledUrl, "/Auth/Proveedor") ||
|
||||
String.Equals(calledUrl, "/Email")
|
||||
)
|
||||
|
@ -1,6 +1,45 @@
|
||||
{
|
||||
"Routes": [
|
||||
|
||||
//CambiarClave
|
||||
|
||||
{
|
||||
"SwaggerKey": "MsAdminUsuarios",
|
||||
|
||||
"UpstreamPathTemplate": "/Auth/CambiarClave",
|
||||
"UpstreamHttpMethod": [ "POST" ],
|
||||
|
||||
"DownstreamPathTemplate": "/Auth/CambiarClave",
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "localhost",
|
||||
"Port": 8151
|
||||
}
|
||||
],
|
||||
|
||||
"RouteClaimsRequirement": {
|
||||
"permisos": "any"
|
||||
}
|
||||
},
|
||||
{
|
||||
"SwaggerKey": "MsAdminUsuarios",
|
||||
"UpstreamPathTemplate": "/Auth/TknCambioClave",
|
||||
"UpstreamHttpMethod": [ "GET" ],
|
||||
"DownstreamPathTemplate": "/Auth/TknCambioClave",
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "localhost",
|
||||
"Port": 8151
|
||||
}
|
||||
],
|
||||
|
||||
"RouteClaimsRequirement": {
|
||||
"permisos": "any"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"SwaggerKey": "MsAdminUsuarios",
|
||||
|
||||
@ -348,12 +387,33 @@
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
"SwaggerKey": "MsAdminUsuarios",
|
||||
"UpstreamPathTemplate": "/TESTERROR",
|
||||
"UpstreamPathTemplate": "/Usuarios/Firma",
|
||||
"UpstreamHttpMethod": [ "GET" ],
|
||||
|
||||
"DownstreamPathTemplate": "/Usuarios/Firma",
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "localhost",
|
||||
"Port": 8151
|
||||
}
|
||||
],
|
||||
|
||||
"RouteClaimsRequirement": {
|
||||
"permisos": "any"
|
||||
}
|
||||
},
|
||||
{
|
||||
"SwaggerKey": "MsAdminUsuarios",
|
||||
"UpstreamPathTemplate": "/Usuarios/Firma",
|
||||
"UpstreamHttpMethod": [ "PATCH" ],
|
||||
|
||||
"DownstreamPathTemplate": "/Usuarios/TESTERROR",
|
||||
"DownstreamPathTemplate": "/Usuarios/Firma",
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
|
File diff suppressed because one or more lines are too long
35
Microservicios/MsUsuarios/.vscode/launch.json
vendored
Normal file
35
Microservicios/MsUsuarios/.vscode/launch.json
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
// Use IntelliSense to find out which attributes exist for C# debugging
|
||||
// Use hover for the description of the existing attributes
|
||||
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
|
||||
"name": ".NET Core Launch (web)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
// If you have changed target frameworks, make sure to update the program path.
|
||||
"program": "${workspaceFolder}/bin/Debug/net6.0/MSAdminUsuarios.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"stopAtEntry": false,
|
||||
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
|
||||
"serverReadyAction": {
|
||||
"action": "openExternally",
|
||||
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
|
||||
},
|
||||
"env": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"sourceFileMap": {
|
||||
"/Views": "${workspaceFolder}/Views"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach"
|
||||
}
|
||||
]
|
||||
}
|
41
Microservicios/MsUsuarios/.vscode/tasks.json
vendored
Normal file
41
Microservicios/MsUsuarios/.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"build",
|
||||
"${workspaceFolder}/MSAdminUsuarios.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "publish",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"publish",
|
||||
"${workspaceFolder}/MSAdminUsuarios.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "watch",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"watch",
|
||||
"run",
|
||||
"--project",
|
||||
"${workspaceFolder}/MSAdminUsuarios.csproj"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
]
|
||||
}
|
@ -75,6 +75,8 @@ namespace MSAdminUsuarios.Context
|
||||
.HasName("USUARIOSMS_PK");
|
||||
|
||||
entity.ToTable("USUARIOSMS");
|
||||
|
||||
entity.Property(e => e.CL_FIRMA_USUMS).HasColumnType("CLOB");
|
||||
});
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
|
@ -22,5 +22,8 @@ namespace MSAdminUsuarios.Context
|
||||
public int? NU_TIPODOC_USUMS { get; set; }
|
||||
public int? NU_PK_USUMS { get; set; }
|
||||
|
||||
public string? CL_FIRMA_USUMS { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ namespace MSAdminUsuarios.Controllers
|
||||
var securityTokenDescriptor = new SecurityTokenDescriptor
|
||||
{
|
||||
Subject = claims,
|
||||
Expires = DateTime.Now.AddMinutes(20),
|
||||
Expires = DateTime.UtcNow.AddMinutes(20),
|
||||
SigningCredentials = signingCredentials
|
||||
};
|
||||
|
||||
|
@ -3,6 +3,8 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using MSAdminUsuarios.Dto;
|
||||
using Security;
|
||||
using MSAdminUsuarios.Models;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace MSAdminUsuarios.Controllers
|
||||
{
|
||||
@ -24,7 +26,7 @@ namespace MSAdminUsuarios.Controllers
|
||||
ErrorModel _errorModel = new ErrorModel();
|
||||
try
|
||||
{
|
||||
if(TX_IDENTIFICACION_AFIL == null)
|
||||
if (TX_IDENTIFICACION_AFIL == null)
|
||||
{
|
||||
_errorModel.error = true;
|
||||
_errorModel.cuerpo.Add("Ingrese un dato");
|
||||
@ -45,7 +47,7 @@ namespace MSAdminUsuarios.Controllers
|
||||
return Ok(_errorModel);
|
||||
|
||||
}
|
||||
catch(Exception)
|
||||
catch (Exception)
|
||||
{
|
||||
_errorModel.error = true;
|
||||
_errorModel.cuerpo.Add("Problemas con la base de datos");
|
||||
@ -98,27 +100,6 @@ namespace MSAdminUsuarios.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
//[HttpGet("TESTERROR")]
|
||||
//public async Task<IActionResult> GetError()
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// List<string> consulta = new List<string>();
|
||||
|
||||
// consulta.Add("Total errores: 10");
|
||||
// consulta.Add("guardados: 5");
|
||||
// consulta.Add("erroneos: 5");
|
||||
// consulta.Add("error #1: hskbjnklsnñksnñksnmñskñkmss");
|
||||
// consulta.Add("error #2: hskbjnklsnñksnñksnmñskñkmss");
|
||||
// consulta.Add("error #3: hskbjnklsnñksnñksnmñskñkmss");
|
||||
|
||||
// return Ok(consulta);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// return BadRequest(ex);
|
||||
// }
|
||||
//}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> GuardarUsuarios(USUARIO usuario)
|
||||
@ -319,6 +300,100 @@ namespace MSAdminUsuarios.Controllers
|
||||
return _errorModel;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPatch("Firma")]
|
||||
public async Task<IActionResult> EditarFirma(USUARIO inputData)
|
||||
{
|
||||
ErrorModel _errorModel = new();
|
||||
using (var dbContextTransaction = _context.Database.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
#region Validaciones
|
||||
|
||||
if ((inputData == null || inputData.CL_FIRMA_USUMS == null) ||
|
||||
(String.IsNullOrEmpty(inputData.CL_FIRMA_USUMS.Trim()) ||
|
||||
String.IsNullOrWhiteSpace(inputData.CL_FIRMA_USUMS.Trim())))
|
||||
{
|
||||
_errorModel.error = true;
|
||||
_errorModel.cuerpo.Add("No se recibió la información requerida.");
|
||||
return Conflict(_errorModel);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// Busco el usuario
|
||||
var found = _context.USUARIOSMs.FirstOrDefault(x => x.NU_PK_USUMS == inputData.NU_PK_USUMS);
|
||||
|
||||
if (found == null)
|
||||
{
|
||||
_errorModel.error = true;
|
||||
_errorModel.cuerpo.Add("El usuario seleccionado no existe.");
|
||||
return Conflict(_errorModel);
|
||||
}
|
||||
|
||||
found.CL_FIRMA_USUMS = inputData.CL_FIRMA_USUMS;
|
||||
|
||||
_context.USUARIOSMs.Update(found);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
await dbContextTransaction.CommitAsync();
|
||||
|
||||
_errorModel.cuerpo.Add("Firma actualizada correctamente.");
|
||||
return Ok(_errorModel);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dbContextTransaction.Rollback();
|
||||
|
||||
_errorModel.error = true;
|
||||
_errorModel.cuerpo.Add("Ocurrió un error en la base de datos.");
|
||||
_errorModel.cuerpo.Add("Por favor intente de nuevo más tarde");
|
||||
|
||||
//_errorModel.debugInfo(e.InnerException.ToString());
|
||||
|
||||
return BadRequest(_errorModel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[HttpGet("Firma")]
|
||||
public async Task<IActionResult> Get(int PK)
|
||||
{
|
||||
ErrorModel _errorModel = new ErrorModel();
|
||||
try
|
||||
{
|
||||
var result = await _context.USUARIOSMs.FirstOrDefaultAsync(dt => dt.NU_PK_USUMS == PK);
|
||||
|
||||
if(result == null)
|
||||
{
|
||||
_errorModel.error = true;
|
||||
_errorModel.cuerpo.Add("Usuario no encontrado");
|
||||
return BadRequest(_errorModel);
|
||||
}
|
||||
|
||||
if (String.IsNullOrEmpty(result.CL_FIRMA_USUMS) ||
|
||||
String.IsNullOrWhiteSpace(result.CL_FIRMA_USUMS.Trim()))
|
||||
{
|
||||
_errorModel.error = true;
|
||||
_errorModel.cuerpo.Add("El usuario no tiene firma.");
|
||||
return Conflict(_errorModel);
|
||||
}
|
||||
|
||||
return Ok(result.CL_FIRMA_USUMS);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_errorModel.error = true;
|
||||
_errorModel.cuerpo.Add("Problema con la base de datos.");
|
||||
|
||||
return BadRequest(_errorModel);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
20
Microservicios/MsUsuarios/Dto/UsuarioDTO.cs
Normal file
20
Microservicios/MsUsuarios/Dto/UsuarioDTO.cs
Normal file
@ -0,0 +1,20 @@
|
||||
namespace MSAdminUsuarios.Dto
|
||||
{
|
||||
public class UsuarioDTO
|
||||
{
|
||||
public string TX_PKDOC_USUMS { get; set; } = null!;
|
||||
public string? TX_LOGINNAME_USUMS { get; set; }
|
||||
public string? TX_PRIMERNOM_USUMS { get; set; }
|
||||
public string? TX_SEGUNDONOM_USUMS { get; set; }
|
||||
public string? TX_PRIMERAPELL_USUMS { get; set; }
|
||||
public string? TX_SEGUNDOAPELL_USUMS { get; set; }
|
||||
public string? TX_DIRECCION_USUMS { get; set; }
|
||||
public string? TX_TELEFONO_USUMS { get; set; }
|
||||
public string? TX_CELULAR_USUMS { get; set; }
|
||||
public string? TX_CORREO_USUMS { get; set; }
|
||||
public int? NU_ESTADO_USUMS { get; set; } = 1;
|
||||
public string? TX_PASSWORD_USUMS { get; set; }
|
||||
public int? NU_TIPODOC_USUMS { get; set; }
|
||||
public int? NU_PK_USUMS { get; set; }
|
||||
}
|
||||
}
|
@ -14,10 +14,10 @@
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "https://localhost:7292;http://localhost:5292",
|
||||
"applicationUrl": "https://localhost:7292;http://localhost:8151",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"MySecretKey": "_ll@v3Segur1d4d!123",
|
||||
"MySecretKey": "_ll@v3Segur1d4d!123"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
|
Loading…
Reference in New Issue
Block a user