me traigo todos los cambios del recuperar cuenta y set email respaldo
This commit is contained in:
@@ -2,6 +2,7 @@ using AlquilaFacil.Builder;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Modelo;
|
using Modelo;
|
||||||
using Entidades;
|
using Entidades;
|
||||||
|
using AlquilaFacil.Emailer.Sender;
|
||||||
|
|
||||||
namespace AlquilaFacil.Controllers;
|
namespace AlquilaFacil.Controllers;
|
||||||
|
|
||||||
@@ -51,7 +52,15 @@ public class UsuarioController : ControllerBase
|
|||||||
if (!emailrecuperacion.Contains("@")) return BadRequest(new { message = "Tiene que ser un email" });
|
if (!emailrecuperacion.Contains("@")) return BadRequest(new { message = "Tiene que ser un email" });
|
||||||
|
|
||||||
bool ret = RepositorioUsuarios.Singleton.SetEmailRecuperacion(emailrecuperacion, cli);
|
bool ret = RepositorioUsuarios.Singleton.SetEmailRecuperacion(emailrecuperacion, cli);
|
||||||
return ret ? Ok(new { message = "Email de recuperación actualizado con éxito" }) : BadRequest(new { message = "No se pudo actualizar el email de recuperación" });
|
if (ret == false) return BadRequest(new { message = "No se pudo actualizar el email de recuperación" });
|
||||||
|
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
AvisoEmailSender s = new();
|
||||||
|
s.Send(cli.Email, setemail.EmailRecuperacion);
|
||||||
|
});
|
||||||
|
|
||||||
|
return Ok(new { message = "Email de recuperación actualizado con éxito" });
|
||||||
}
|
}
|
||||||
|
|
||||||
public record recuperarusuario(string Email, string EmailRecuperacion);
|
public record recuperarusuario(string Email, string EmailRecuperacion);
|
||||||
@@ -61,7 +70,34 @@ public class UsuarioController : ControllerBase
|
|||||||
bool check = RepositorioUsuarios.Singleton.CheckEmailRecuperacion(mails.Email, mails.EmailRecuperacion);
|
bool check = RepositorioUsuarios.Singleton.CheckEmailRecuperacion(mails.Email, mails.EmailRecuperacion);
|
||||||
if (check == false) return BadRequest(new { message = "El email no corresponde al email de recuperacion" });
|
if (check == false) return BadRequest(new { message = "El email no corresponde al email de recuperacion" });
|
||||||
|
|
||||||
//WIP hacer emailer
|
string pin = "";
|
||||||
|
var ran = new Random();
|
||||||
|
for (int i = 0; i < 6; i++) pin += ran.Next(0, 10);
|
||||||
|
|
||||||
|
bool ret = RepositorioUsuarios.Singleton.SetF2aPin(pin, mails.Email);
|
||||||
|
if (ret == false) return BadRequest(new { message = "no se pudo generar/guardar el codigo 2fa" });
|
||||||
|
|
||||||
|
OtpEmailSender s = new();
|
||||||
|
s.Send(mails.EmailRecuperacion, mails.Email, pin);
|
||||||
|
|
||||||
|
return Ok(new { message = $"Se envio un email de recuperacion a {mails.EmailRecuperacion}" });
|
||||||
|
}
|
||||||
|
|
||||||
|
public record ingreso2fa(string Pin, string Email);
|
||||||
|
[HttpPost("/api/ingresar2fa")]
|
||||||
|
public IActionResult IngresarUsuario([FromBody] ingreso2fa data)
|
||||||
|
{
|
||||||
|
if (!data.Email.Contains("@")) return BadRequest(new { message = "Tiene que ser un email" });
|
||||||
|
if (data.Pin.Length != 6) return BadRequest(new { message = "el pin tiene que tener 6 digitos" });
|
||||||
|
|
||||||
|
(bool check, long Dni) = RepositorioUsuarios.Singleton.Check2fa(data.Email, data.Pin);
|
||||||
|
if (check == false) return BadRequest(new { message = "El pin es incorrecto" });
|
||||||
|
|
||||||
|
var cli = RepositorioUsuarios.Singleton.ObtenerClientePorDni(Dni);
|
||||||
|
|
||||||
|
//esto literalmente no se puede triggerear pero lo pongo para evitar una warning
|
||||||
|
if (cli == null) return BadRequest(new { message = "El usuario no existe" });
|
||||||
|
|
||||||
|
return Ok(new { token = cli.Token });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,10 +17,20 @@ public class EmailBuilder
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmailBuilder Body(string email, string pin)
|
public EmailBuilder Body(string email, string pin, string modo = "2fa")
|
||||||
{
|
{
|
||||||
_message.IsBodyHtml = true;
|
_message.IsBodyHtml = true;
|
||||||
_message.Body = new HtmlGenerator().GenerarMail2fa(email, pin);
|
switch (modo)
|
||||||
|
{
|
||||||
|
case "2fa":
|
||||||
|
_message.Body = new HtmlGenerator().GenerarMail2fa(email, pin);
|
||||||
|
break;
|
||||||
|
case "aviso":
|
||||||
|
_message.Body = new HtmlGenerator().AvisoSetEmail(email, pin);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,4 +55,58 @@ public class HtmlGenerator
|
|||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
public string AvisoSetEmail(string emailUsuario, string emailreq)
|
||||||
|
{
|
||||||
|
var msg = $"""
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<div
|
||||||
|
style='background-color:#000000;color:#FFFFFF;font-family:"Iowan Old Style", "Palatino Linotype", "URW Palladio L", P052, serif;font-size:16px;font-weight:400;letter-spacing:0.15008px;line-height:1.5;margin:0;padding:32px 0;min-height:100%;width:100%'
|
||||||
|
>
|
||||||
|
<table
|
||||||
|
align="center"
|
||||||
|
width="100%"
|
||||||
|
style="margin:0 auto;max-width:600px;background-color:#000000"
|
||||||
|
role="presentation"
|
||||||
|
cellspacing="0"
|
||||||
|
cellpadding="0"
|
||||||
|
border="0"
|
||||||
|
>
|
||||||
|
<tbody>
|
||||||
|
<tr style="width:100%">
|
||||||
|
<td>
|
||||||
|
<div
|
||||||
|
style="color:#ffffff;font-size:16px;font-weight:normal;text-align:center;padding:16px 24px 16px 24px"
|
||||||
|
>
|
||||||
|
Aviso:
|
||||||
|
</div>
|
||||||
|
<h1
|
||||||
|
style='font-weight:bold;text-align:center;margin:0;font-family:"Nimbus Mono PS", "Courier New", "Cutive Mono", monospace;font-size:32px;padding:16px 24px 16px 24px'
|
||||||
|
>
|
||||||
|
Se seteo este email : {emailreq}, como email de respaldo
|
||||||
|
</h1>
|
||||||
|
<div
|
||||||
|
style="color:#868686;font-size:16px;font-weight:normal;text-align:center;padding:16px 24px 16px 24px"
|
||||||
|
>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
style="color:#868686;font-size:14px;font-weight:normal;text-align:center;padding:16px 24px 16px 24px"
|
||||||
|
>
|
||||||
|
Si no sabes para que es el email, ignoralo.
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
""";
|
||||||
|
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
11
Aspnet/Emailer/Decorator/AvisoEmailSender.cs
Normal file
11
Aspnet/Emailer/Decorator/AvisoEmailSender.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
namespace AlquilaFacil.Emailer.Sender;
|
||||||
|
using AlquilaFacil.Emailer.Builder;
|
||||||
|
|
||||||
|
public class AvisoEmailSender : EmailSender
|
||||||
|
{
|
||||||
|
public void Send(string emailusu, string emailreq)
|
||||||
|
{
|
||||||
|
var mail = new EmailBuilder().Body(emailusu, emailreq, "aviso").To(emailreq).Subject("AvisoEmail").Build();
|
||||||
|
base.Send(mail);
|
||||||
|
}
|
||||||
|
}
|
||||||
50
Aspnet/Emailer/Decorator/EmailerSender.cs
Normal file
50
Aspnet/Emailer/Decorator/EmailerSender.cs
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
using System.Net.Mail;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace AlquilaFacil.Emailer.Sender;
|
||||||
|
|
||||||
|
public class EmailSender
|
||||||
|
{
|
||||||
|
protected static SmtpClient? smtp = null;
|
||||||
|
protected void configSmtp(MailMessage mail)
|
||||||
|
{
|
||||||
|
var jsonContent = File.ReadAllText("settings.json");
|
||||||
|
var options = JsonSerializer.Deserialize<Dictionary<string, string>>(jsonContent);
|
||||||
|
if (options == null) return;
|
||||||
|
|
||||||
|
|
||||||
|
bool check = options.ContainsKey("smtpHost");
|
||||||
|
check = options.ContainsKey("smtpPort");
|
||||||
|
check = options.ContainsKey("emailAddr");
|
||||||
|
check = options.ContainsKey("emailPass");
|
||||||
|
|
||||||
|
if (check == false) return;
|
||||||
|
mail.Sender = new MailAddress(options["emailAddr"]);
|
||||||
|
mail.From = new MailAddress(options["emailAddr"]);
|
||||||
|
|
||||||
|
if (null != smtp) return;
|
||||||
|
smtp = new();
|
||||||
|
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
|
||||||
|
smtp.EnableSsl = true;
|
||||||
|
smtp.Host = options["smtpHost"];
|
||||||
|
smtp.Port = int.Parse(options["smtpPort"].ToString());
|
||||||
|
smtp.Credentials = new NetworkCredential(options["emailAddr"], options["emailPass"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void Send(MailMessage message)
|
||||||
|
{
|
||||||
|
configSmtp(message);
|
||||||
|
if (smtp == null) return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
smtp.Send(message);
|
||||||
|
message.Dispose();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
using System.Net.Mail;
|
|
||||||
|
|
||||||
namespace AlquilaFacil.Emailer.Sender;
|
|
||||||
|
|
||||||
public interface IEmailSender
|
|
||||||
{
|
|
||||||
public void Send(MailMessage message, SmtpClient smtp);
|
|
||||||
|
|
||||||
}
|
|
||||||
13
Aspnet/Emailer/Decorator/OtpEmailSender.cs
Normal file
13
Aspnet/Emailer/Decorator/OtpEmailSender.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
namespace AlquilaFacil.Emailer.Sender;
|
||||||
|
using AlquilaFacil.Emailer.Builder;
|
||||||
|
public class OtpEmailSender : EmailSender
|
||||||
|
{
|
||||||
|
|
||||||
|
public void Send(string To, string email, string pin)
|
||||||
|
{
|
||||||
|
var mail = new EmailBuilder().To(To).Body(email, pin).Subject("Mail de Recuperacion").Build();
|
||||||
|
|
||||||
|
base.Send(mail);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
namespace AlquilaFacil.Emailer.Sender;
|
|
||||||
using System.Net.Mail;
|
|
||||||
public class OtpEmailSender : IEmailSender
|
|
||||||
{
|
|
||||||
private readonly int _codigoLength;
|
|
||||||
|
|
||||||
public OtpEmailSenderDecorator(int codigoLength = 6)
|
|
||||||
{
|
|
||||||
_codigoLength = codigoLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Send(MailMessage message, SmtpClient? smtp = null)
|
|
||||||
{
|
|
||||||
if (smtp == null)
|
|
||||||
{
|
|
||||||
smtp = new();
|
|
||||||
//WIP
|
|
||||||
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 4.2 Construir HTML de verificación
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
{
|
{
|
||||||
"usr": "nwFNMLJcn5m0owbzeXMs",
|
"usr": "nwFNMLJcn5m0owbzeXMs",
|
||||||
"scrt": "Mf9HxTir5mIGwWSBtQXd6DRK2k00V0EyXk7QTu70",
|
"scrt": "Mf9HxTir5mIGwWSBtQXd6DRK2k00V0EyXk7QTu70",
|
||||||
"connectiondb": "Server=127.0.0.1;Port=3306;Database=AlquilaFacil;Uid=AlquilaFacil;Pwd=.n@9c2ve*0,b1ETv].Kipa/~pR~V;Connection Timeout=5;SslMode=none"
|
"connectiondb": "Server=127.0.0.1;Port=3306;Database=AlquilaFacil;Uid=AlquilaFacil;Pwd=.n@9c2ve*0,b1ETv].Kipa/~pR~V;Connection Timeout=5;SslMode=none",
|
||||||
|
"smtpHost": "smtp.gmail.com",
|
||||||
|
"smtpPort": "587",
|
||||||
|
"emailAddr": "emailerpasillo@gmail.com",
|
||||||
|
"emailPass": "hgwa mznx xuff exws"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,6 +136,9 @@ public partial class AlquilaFacilContext : DbContext
|
|||||||
entity.Property(e => e.EmailRecuperacion)
|
entity.Property(e => e.EmailRecuperacion)
|
||||||
.HasMaxLength(50)
|
.HasMaxLength(50)
|
||||||
.HasColumnName("emailRecuperacion");
|
.HasColumnName("emailRecuperacion");
|
||||||
|
entity.Property(e => e.F2a)
|
||||||
|
.HasMaxLength(6)
|
||||||
|
.HasColumnName("f2a");
|
||||||
entity.Property(e => e.Habilitado)
|
entity.Property(e => e.Habilitado)
|
||||||
.HasDefaultValueSql("b'1'")
|
.HasDefaultValueSql("b'1'")
|
||||||
.HasColumnType("bit(1)")
|
.HasColumnType("bit(1)")
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Entidades;
|
namespace Entidades;
|
||||||
@@ -25,6 +25,9 @@ public partial class Cliente
|
|||||||
|
|
||||||
public string? EmailRecuperacion { get; set; }
|
public string? EmailRecuperacion { get; set; }
|
||||||
|
|
||||||
|
public string? F2a { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public virtual ICollection<Contrato> ContratoDniinquilinoNavigations { get; set; } = new List<Contrato>();
|
public virtual ICollection<Contrato> ContratoDniinquilinoNavigations { get; set; } = new List<Contrato>();
|
||||||
|
|
||||||
public virtual ICollection<Contrato> ContratoDnipropietarioNavigations { get; set; } = new List<Contrato>();
|
public virtual ICollection<Contrato> ContratoDnipropietarioNavigations { get; set; } = new List<Contrato>();
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Entidades;
|
|
||||||
|
|
||||||
public partial class EstadoPropiedad
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
public string Descripcion { get; set; } = null!;
|
|
||||||
|
|
||||||
public virtual ICollection<Propiedade> Propiedades { get; set; } = new List<Propiedade>();
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Entidades;
|
namespace Entidades;
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Entidades;
|
|
||||||
|
|
||||||
public partial class LogDetalle
|
|
||||||
{
|
|
||||||
public DateTime Fecha { get; set; }
|
|
||||||
|
|
||||||
public long Dniusuario { get; set; }
|
|
||||||
|
|
||||||
public string NombreTabla { get; set; } = null!;
|
|
||||||
|
|
||||||
public string Columna { get; set; } = null!;
|
|
||||||
|
|
||||||
public string? ValorAnterior { get; set; }
|
|
||||||
|
|
||||||
public string? ValorNuevo { get; set; }
|
|
||||||
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
public virtual Log Log { get; set; } = null!;
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Entidades;
|
namespace Entidades;
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Entidades;
|
|
||||||
|
|
||||||
public partial class TipoPropiedad
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
public string Descripcion { get; set; } = null!;
|
|
||||||
|
|
||||||
public virtual ICollection<Propiedade> Propiedades { get; set; } = new List<Propiedade>();
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Entidades;
|
namespace Entidades;
|
||||||
|
|||||||
@@ -50,15 +50,73 @@
|
|||||||
|
|
||||||
let showrecuperarmodal = $state(false);
|
let showrecuperarmodal = $state(false);
|
||||||
let modaldata = $state("");
|
let modaldata = $state("");
|
||||||
|
|
||||||
|
let emailr = $state("");
|
||||||
|
let emailrecovery = $state("");
|
||||||
async function SubmitRecuperarContraseñaEmail(e) {
|
async function SubmitRecuperarContraseñaEmail(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return;
|
|
||||||
try {
|
try {
|
||||||
const req = await fetch($urlG + "");
|
const req = await fetch($urlG + "/api/recuperarUsuario", {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({
|
||||||
|
Email: emailr,
|
||||||
|
EmailRecuperacion: emailrecovery,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
const data = await req.json();
|
||||||
|
showrecuperarmodal = false;
|
||||||
|
if (req.ok) {
|
||||||
|
showf2amodal = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//hago esto para que no puedan haber errores en caso de que intente recuperar 1 cuenta, aborte y intente recuperar una segunda
|
||||||
|
emailr = "";
|
||||||
|
emailrecovery = "";
|
||||||
|
//
|
||||||
|
modaldata = data.message;
|
||||||
} catch {
|
} catch {
|
||||||
modaldata = "Fallo al hacer la request";
|
modaldata = "Fallo al hacer la request";
|
||||||
}
|
}
|
||||||
} //WIP
|
}
|
||||||
|
|
||||||
|
let showf2amodal = $state(false);
|
||||||
|
async function submitf2a(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
const inputs = document.querySelectorAll(".otp-input");
|
||||||
|
|
||||||
|
let otppin = "";
|
||||||
|
|
||||||
|
inputs.forEach((x) => {
|
||||||
|
otppin += x.value.trim();
|
||||||
|
});
|
||||||
|
if (otppin.length != 6) {
|
||||||
|
modaldata = "la longitud del pin es incorrecta";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (emailr == "") {
|
||||||
|
modaldata = "Fallo vuelva a intentar";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const req = await fetch($urlG + "/api/ingresar2fa", {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({ Pin: otppin, Email: emailr }),
|
||||||
|
});
|
||||||
|
const data = await req.json();
|
||||||
|
if (req.ok) {
|
||||||
|
sessionStorage.setItem("token", data.token);
|
||||||
|
localStorage.setItem("email", emailr);
|
||||||
|
showf2amodal = false;
|
||||||
|
navigate("/usuario");
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
modaldata = "Fallo al hacer la request";
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if modaldata}
|
{#if modaldata}
|
||||||
@@ -116,6 +174,86 @@
|
|||||||
>
|
>
|
||||||
</CardBody>
|
</CardBody>
|
||||||
</Card>
|
</Card>
|
||||||
|
{#if showf2amodal}
|
||||||
|
<div
|
||||||
|
class="modal"
|
||||||
|
tabindex="-1"
|
||||||
|
style="display: block; background-color: rgba(0, 0, 0, 0.3);"
|
||||||
|
>
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Recuperar Contraseña</h5>
|
||||||
|
</div>
|
||||||
|
<form onsubmit={submitf2a}>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="f2a" class="form-label"
|
||||||
|
>Ingrese el codigo que tendria que haber llegado
|
||||||
|
a su email</label
|
||||||
|
>
|
||||||
|
<div class="d-flex gap-2 justify-content-center">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="form-control text-center otp-input"
|
||||||
|
maxlength="1"
|
||||||
|
inputmode="numeric"
|
||||||
|
pattern="[0-9]*"
|
||||||
|
style="width: 3rem;"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="form-control text-center otp-input"
|
||||||
|
maxlength="1"
|
||||||
|
inputmode="numeric"
|
||||||
|
pattern="[0-9]*"
|
||||||
|
style="width: 3rem;"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="form-control text-center otp-input"
|
||||||
|
maxlength="1"
|
||||||
|
inputmode="numeric"
|
||||||
|
pattern="[0-9]*"
|
||||||
|
style="width: 3rem;"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="form-control text-center otp-input"
|
||||||
|
maxlength="1"
|
||||||
|
inputmode="numeric"
|
||||||
|
pattern="[0-9]*"
|
||||||
|
style="width: 3rem;"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="form-control text-center otp-input"
|
||||||
|
maxlength="1"
|
||||||
|
inputmode="numeric"
|
||||||
|
pattern="[0-9]*"
|
||||||
|
style="width: 3rem;"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="form-control text-center otp-input"
|
||||||
|
maxlength="1"
|
||||||
|
inputmode="numeric"
|
||||||
|
pattern="[0-9]*"
|
||||||
|
style="width: 3rem;"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer d-flex">
|
||||||
|
<button type="submit" class="btn btn-primary">
|
||||||
|
Enviar
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if showrecuperarmodal}
|
{#if showrecuperarmodal}
|
||||||
<div
|
<div
|
||||||
@@ -136,16 +274,28 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<form onsubmit={SubmitRecuperarContraseñaEmail}>
|
<form onsubmit={SubmitRecuperarContraseñaEmail}>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="Email" class="form-label">Email</label>
|
||||||
|
<input
|
||||||
|
type="email"
|
||||||
|
class="form-control"
|
||||||
|
id="Email"
|
||||||
|
placeholder="Ingresa tu email"
|
||||||
|
required
|
||||||
|
bind:value={emailr}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="recoveryEmail" class="form-label"
|
<label for="recoveryEmail" class="form-label"
|
||||||
>Email</label
|
>Email Recuperacion</label
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
type="email"
|
type="email"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
id="recoveryEmail"
|
id="recoveryEmail"
|
||||||
placeholder="Ingresa tu email"
|
placeholder="Ingresa tu email de recuperacion"
|
||||||
required
|
required
|
||||||
|
bind:value={emailrecovery}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-grid gap-2">
|
<div class="d-grid gap-2">
|
||||||
|
|||||||
@@ -11,6 +11,28 @@ namespace Modelo;
|
|||||||
|
|
||||||
public class RepositorioUsuarios : RepositorioBase<RepositorioUsuarios>
|
public class RepositorioUsuarios : RepositorioBase<RepositorioUsuarios>
|
||||||
{
|
{
|
||||||
|
public (bool, long) Check2fa(string Email, string Pin)
|
||||||
|
{
|
||||||
|
var con = Context;
|
||||||
|
var cli = con.Clientes.FirstOrDefault(x => x.Email == Email);
|
||||||
|
if (cli == null || cli.F2a == null) return (false, 0);
|
||||||
|
|
||||||
|
if (cli.F2a != Pin) return (false, 0);
|
||||||
|
|
||||||
|
return (true, cli.Dni);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SetF2aPin(string pin, string Email)
|
||||||
|
{
|
||||||
|
if (pin.Length != 6) return false;
|
||||||
|
var con = Context;
|
||||||
|
var cli = con.Clientes.FirstOrDefault(x => x.Email == Email);
|
||||||
|
if (cli == null) return false;
|
||||||
|
|
||||||
|
cli.F2a = pin;
|
||||||
|
//no Necesita logs esto
|
||||||
|
return Guardar(con);
|
||||||
|
}
|
||||||
public bool CheckEmailRecuperacion(string Email, string EmailRecuperacion)
|
public bool CheckEmailRecuperacion(string Email, string EmailRecuperacion)
|
||||||
{
|
{
|
||||||
var con = Context;
|
var con = Context;
|
||||||
|
|||||||
Reference in New Issue
Block a user