añadido que logee la ip y los logins
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Net;
|
||||
using Entidades;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
@@ -28,6 +29,31 @@ public class AuditoriaFacade {
|
||||
_persistenciaDeLog.GuardarLog(log, log.LogDetalles);
|
||||
}
|
||||
|
||||
internal void GenerarLogLogin(long dni, string v, IPAddress? remoteIpAddress) {
|
||||
var fechaActual = DateTime.Now;
|
||||
|
||||
var log = new Log{
|
||||
Fecha = fechaActual,
|
||||
Dniusuario = dni,
|
||||
Accion = v
|
||||
};
|
||||
|
||||
log.LogDetalles = new List<LogDetalle>([
|
||||
new LogDetalle{
|
||||
Id = 1,
|
||||
Dniusuario = dni,
|
||||
Fecha = fechaActual,
|
||||
NombreTabla = "Logs",
|
||||
Columna = "Login",
|
||||
ValorAnterior = "",
|
||||
ValorNuevo = $"Se inicio sesión con la direccion ip: {remoteIpAddress.ToString()}",
|
||||
}
|
||||
]);
|
||||
|
||||
_persistenciaDeLog.GuardarLog(log, log.LogDetalles);
|
||||
|
||||
}
|
||||
|
||||
private List<LogDetalle> ProcesarCambios(IEnumerable<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry> cambios,
|
||||
DateTime fechaActual, long dniUsuario) {
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ using Entidades.Dto;
|
||||
using Entidades;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Entidades.Admin;
|
||||
using System.Net;
|
||||
using Modelo.Facade;
|
||||
|
||||
namespace Modelo;
|
||||
|
||||
@@ -95,14 +97,22 @@ public class RepositorioUsuarios: RepositorioBase<RepositorioUsuarios> {
|
||||
return usu.Token == token;
|
||||
}
|
||||
|
||||
public void GuardarToken(LoginDto login, string tokenString) {
|
||||
public void GuardarToken(LoginDto login, string tokenString, System.Net.IPAddress? remoteIpAddress) {
|
||||
var con = Context;
|
||||
var usu = con.Clientes.FirstOrDefault(x => x.Email == login.Email);
|
||||
if (usu == null) return;
|
||||
usu.Token = tokenString;
|
||||
GenerarLog(con, usu.Dni, "Login", remoteIpAddress);
|
||||
Guardar(con);
|
||||
}
|
||||
|
||||
private void GenerarLog(AlquilaFacilContext con, long dni, string v, IPAddress? remoteIpAddress)
|
||||
{
|
||||
var Auditoria = new AuditoriaFacade(con);
|
||||
Auditoria.GenerarLogLogin(dni, v, remoteIpAddress);
|
||||
|
||||
}
|
||||
|
||||
public bool CheckGrupo(string email, string grupo) {
|
||||
var con = Context;
|
||||
var usu = con.Clientes.Include(x=>x.Idgrupos).FirstOrDefault(x=>x.Email == email);
|
||||
|
||||
Reference in New Issue
Block a user