emilsoftware-utilities 1.3.142 → 1.3.143
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -40,6 +40,7 @@ let EmailService = class EmailService {
|
|
|
40
40
|
}
|
|
41
41
|
sendPasswordResetEmail(email) {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
var _a;
|
|
43
44
|
try {
|
|
44
45
|
const resetToken = (0, uuid_1.v4)(); // Generiamo un nuovo token unico
|
|
45
46
|
// Aggiorna il campo keyReg nel database
|
|
@@ -47,7 +48,7 @@ let EmailService = class EmailService {
|
|
|
47
48
|
if (result.length === 0) {
|
|
48
49
|
throw new Error("Email non trovata.");
|
|
49
50
|
}
|
|
50
|
-
const returnUrlQueryParams = "?returnUrl=" + this.accessiOptions.confirmationEmailReturnUrl;
|
|
51
|
+
const returnUrlQueryParams = "?returnUrl=" + this.accessiOptions.confirmationEmailReturnUrl + "&prefix=" + ((_a = this.accessiOptions.confirmationEmailPrefix) !== null && _a !== void 0 ? _a : '');
|
|
51
52
|
const { confirmationEmailUrl } = this.accessiOptions;
|
|
52
53
|
const resetUrl = `${confirmationEmailUrl}/api/accessi/email/reset-password-page/${resetToken}${returnUrlQueryParams}`;
|
|
53
54
|
let sPhrase;
|
|
@@ -104,6 +104,7 @@
|
|
|
104
104
|
<form id="resetForm">
|
|
105
105
|
<input type="hidden" id="token" value="">
|
|
106
106
|
<input type="hidden" id="returnUrl" value="">
|
|
107
|
+
<input type="hidden" id="prefix" value="">
|
|
107
108
|
|
|
108
109
|
<div class="form-group">
|
|
109
110
|
<label for="password">Nuova Password:</label>
|
|
@@ -126,9 +127,11 @@
|
|
|
126
127
|
const urlParams = new URLSearchParams(window.location.search);
|
|
127
128
|
const token = window.location.pathname.split("/").pop();
|
|
128
129
|
const returnUrl = urlParams.get("returnUrl") || "/";
|
|
130
|
+
const prefix = urlParams.get("prefix") || "";
|
|
129
131
|
|
|
130
132
|
document.getElementById("token").value = token;
|
|
131
133
|
document.getElementById("returnUrl").value = returnUrl;
|
|
134
|
+
document.getElementById("prefix").value = prefix;
|
|
132
135
|
|
|
133
136
|
document.getElementById("resetForm").addEventListener("submit", async function (event) {
|
|
134
137
|
event.preventDefault();
|
|
@@ -154,7 +157,7 @@
|
|
|
154
157
|
|
|
155
158
|
// Effettua la richiesta API
|
|
156
159
|
try {
|
|
157
|
-
const response = await fetch(
|
|
160
|
+
const response = await fetch(`${prefix}/api/accessi/auth/confirm-reset-password/${token}`, {
|
|
158
161
|
method: "POST",
|
|
159
162
|
headers: { "Content-Type": "application/json" },
|
|
160
163
|
body: JSON.stringify({ newPassword: password })
|
|
@@ -162,27 +165,20 @@
|
|
|
162
165
|
|
|
163
166
|
const data = await response.json();
|
|
164
167
|
alert(data.message || "Password aggiornata con successo!");
|
|
165
|
-
|
|
166
|
-
|
|
167
168
|
} catch (error) {
|
|
168
169
|
alert("Errore nel reset della password. Riprova più tardi.");
|
|
169
|
-
}
|
|
170
|
-
finally {
|
|
171
|
-
|
|
170
|
+
} finally {
|
|
172
171
|
setTimeout(() => {
|
|
173
|
-
|
|
174
172
|
if (returnUrl.startsWith("https://") || returnUrl.startsWith("http://")) {
|
|
175
173
|
window.location.href = returnUrl;
|
|
176
174
|
} else {
|
|
177
175
|
window.location.href = "https://" + returnUrl;
|
|
178
176
|
}
|
|
179
|
-
|
|
180
177
|
}, 500);
|
|
181
|
-
|
|
182
178
|
}
|
|
183
179
|
});
|
|
184
180
|
});
|
|
185
181
|
</script>
|
|
186
182
|
</body>
|
|
187
183
|
|
|
188
|
-
</html>
|
|
184
|
+
</html>
|