Esta todo a medio hacerse pero quiero versionar esto ya para no perder
nada
This commit is contained in:
@@ -54,4 +54,14 @@ public class UsuarioController : ControllerBase
|
||||
return ret ? Ok(new { message = "Email de recuperación actualizado con éxito" }) : BadRequest(new { message = "No se pudo actualizar el email de recuperación" });
|
||||
}
|
||||
|
||||
public record recuperarusuario(string Email, string EmailRecuperacion);
|
||||
[HttpPost("/api/recuperarUsuario")]
|
||||
public IActionResult RecuperarUsuario([FromBody] recuperarusuario mails)
|
||||
{
|
||||
bool check = RepositorioUsuarios.Singleton.CheckEmailRecuperacion(mails.Email, mails.EmailRecuperacion);
|
||||
if (check == false) return BadRequest(new { message = "El email no corresponde al email de recuperacion" });
|
||||
|
||||
//WIP hacer emailer
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Net.Mail;
|
||||
namespace AlquilaFacil.Emailer.Builder;
|
||||
|
||||
public class EmailBuilder
|
||||
{
|
||||
private MailMessage _message = new();
|
||||
|
||||
public EmailBuilder To(string to)
|
||||
{
|
||||
_message.To.Add(to);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EmailBuilder Subject(string subject)
|
||||
{
|
||||
_message.Subject = subject;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EmailBuilder Body(string email, string pin)
|
||||
{
|
||||
_message.IsBodyHtml = true;
|
||||
_message.Body = new HtmlGenerator().GenerarMail2fa(email, pin);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MailMessage Build() => _message;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
namespace AlquilaFacil.Emailer.Builder;
|
||||
|
||||
public class HtmlGenerator
|
||||
{
|
||||
public string GenerarMail2fa(string emailUsuario, string pin)
|
||||
{
|
||||
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"
|
||||
>
|
||||
Aqui esta su codigo OTP:
|
||||
</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'
|
||||
>
|
||||
{pin}
|
||||
</h1>
|
||||
<div
|
||||
style="color:#868686;font-size:16px;font-weight:normal;text-align:center;padding:16px 24px 16px 24px"
|
||||
>
|
||||
Este codigo es del usuario con email:{emailUsuario}
|
||||
</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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Net.Mail;
|
||||
|
||||
namespace AlquilaFacil.Emailer.Sender;
|
||||
|
||||
public interface IEmailSender
|
||||
{
|
||||
public void Send(MailMessage message, SmtpClient smtp);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
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",
|
||||
"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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user