me traigo todos los cambios del recuperar cuenta y set email respaldo
This commit is contained in:
@@ -50,15 +50,73 @@
|
||||
|
||||
let showrecuperarmodal = $state(false);
|
||||
let modaldata = $state("");
|
||||
|
||||
let emailr = $state("");
|
||||
let emailrecovery = $state("");
|
||||
async function SubmitRecuperarContraseñaEmail(e) {
|
||||
e.preventDefault();
|
||||
return;
|
||||
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 {
|
||||
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>
|
||||
|
||||
{#if modaldata}
|
||||
@@ -116,6 +174,86 @@
|
||||
>
|
||||
</CardBody>
|
||||
</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}
|
||||
<div
|
||||
@@ -136,16 +274,28 @@
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<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">
|
||||
<label for="recoveryEmail" class="form-label"
|
||||
>Email</label
|
||||
>Email Recuperacion</label
|
||||
>
|
||||
<input
|
||||
type="email"
|
||||
class="form-control"
|
||||
id="recoveryEmail"
|
||||
placeholder="Ingresa tu email"
|
||||
placeholder="Ingresa tu email de recuperacion"
|
||||
required
|
||||
bind:value={emailrecovery}
|
||||
/>
|
||||
</div>
|
||||
<div class="d-grid gap-2">
|
||||
|
||||
Reference in New Issue
Block a user