emilsoftware-utilities 1.3.142 → 1.3.144
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.
- package/dist/accessi-module/AccessiModule.d.ts +1 -0
- package/dist/accessi-module/Controllers/UserController.d.ts +1 -1
- package/dist/accessi-module/Controllers/UserController.js +4 -3
- package/dist/accessi-module/Services/EmailService/EmailService.js +2 -1
- package/dist/accessi-module/Services/UserService/UserService.d.ts +1 -1
- package/dist/accessi-module/Services/UserService/UserService.js +11 -4
- package/dist/accessi-module/Views/reset-password.html +16 -9
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ export declare class UserController {
|
|
|
11
11
|
private readonly logger;
|
|
12
12
|
constructor(userService: UserService, emailService: EmailService, options: AccessiOptions);
|
|
13
13
|
serveResetPasswordPage(res: Response, token: string): Promise<void>;
|
|
14
|
-
getUsers(res: Response): Promise<Response<any, Record<string, any>>>;
|
|
14
|
+
getUsers(res: Response, email?: string): Promise<Response<any, Record<string, any>>>;
|
|
15
15
|
deleteUser(codiceUtente: number, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
16
16
|
register(request: Request, registrationData: RegisterRequest, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
17
17
|
updateUtente(codiceUtente: number, user: UserDto, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
@@ -46,10 +46,10 @@ let UserController = UserController_1 = class UserController {
|
|
|
46
46
|
return res.sendFile((0, path_1.join)(__dirname, '..', 'Views', 'reset-password.html'));
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
getUsers(res) {
|
|
49
|
+
getUsers(res, email) {
|
|
50
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
51
|
try {
|
|
52
|
-
const users = yield this.userService.getUsers();
|
|
52
|
+
const users = yield this.userService.getUsers(email);
|
|
53
53
|
return Utilities_1.RestUtilities.sendBaseResponse(res, users);
|
|
54
54
|
}
|
|
55
55
|
catch (error) {
|
|
@@ -127,8 +127,9 @@ __decorate([
|
|
|
127
127
|
(0, swagger_1.ApiResponse)({ status: 401, description: 'Credenziali non valide' }),
|
|
128
128
|
(0, common_1.Get)('get-users'),
|
|
129
129
|
__param(0, (0, common_1.Res)()),
|
|
130
|
+
__param(1, (0, common_1.Query)('email')),
|
|
130
131
|
__metadata("design:type", Function),
|
|
131
|
-
__metadata("design:paramtypes", [Object]),
|
|
132
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
132
133
|
__metadata("design:returntype", Promise)
|
|
133
134
|
], UserController.prototype, "getUsers", null);
|
|
134
135
|
__decorate([
|
|
@@ -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;
|
|
@@ -10,7 +10,7 @@ export declare class UserService {
|
|
|
10
10
|
private readonly emailService;
|
|
11
11
|
private readonly permissionService;
|
|
12
12
|
constructor(accessiOptions: AccessiOptions, emailService: EmailService, permissionService: PermissionService);
|
|
13
|
-
getUsers(): Promise<GetUsersResult[]>;
|
|
13
|
+
getUsers(email?: string): Promise<GetUsersResult[]>;
|
|
14
14
|
getCodiceUtenteByEmail(email: string): Promise<{
|
|
15
15
|
codiceUtente: number;
|
|
16
16
|
}>;
|
|
@@ -35,10 +35,10 @@ let UserService = class UserService {
|
|
|
35
35
|
this.emailService = emailService;
|
|
36
36
|
this.permissionService = permissionService;
|
|
37
37
|
}
|
|
38
|
-
getUsers() {
|
|
38
|
+
getUsers(email) {
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
40
|
try {
|
|
41
|
-
|
|
41
|
+
let query = `
|
|
42
42
|
SELECT
|
|
43
43
|
U.CODUTE as codice_utente,
|
|
44
44
|
U.USRNAME as email,
|
|
@@ -66,10 +66,17 @@ let UserService = class UserService {
|
|
|
66
66
|
F.CODCLIENTI AS codice_clienti,
|
|
67
67
|
F.TIPFIL AS tip_fil
|
|
68
68
|
FROM UTENTI U
|
|
69
|
-
|
|
69
|
+
WHERE 1=1
|
|
70
|
+
`;
|
|
71
|
+
let queryParams = [];
|
|
72
|
+
if (email) {
|
|
73
|
+
query += ` AND LOWER(U.USRNAME) = ? `;
|
|
74
|
+
queryParams.push(email.trim().toLowerCase());
|
|
75
|
+
}
|
|
76
|
+
query += `INNER JOIN UTENTI_CONFIG G ON U.CODUTE = G.CODUTE
|
|
70
77
|
LEFT JOIN FILTRI F ON F.CODUTE = U.CODUTE
|
|
71
78
|
ORDER BY U.CODUTE`;
|
|
72
|
-
let users = yield Orm_1.Orm.query(this.accessiOptions.databaseOptions, query);
|
|
79
|
+
let users = yield Orm_1.Orm.query(this.accessiOptions.databaseOptions, query, queryParams);
|
|
73
80
|
users = users.map(Utilities_1.RestUtilities.convertKeysToCamelCase);
|
|
74
81
|
let usersResponse = [];
|
|
75
82
|
for (const user of users) {
|
|
@@ -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,22 @@
|
|
|
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
|
+
let prefix = urlParams.get("prefix") || "";
|
|
131
|
+
|
|
132
|
+
if (prefix !== "") {
|
|
133
|
+
if (!prefix.startsWith("/")) {
|
|
134
|
+
prefix = "/" + prefix;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if(prefix.endsWith("/")) {
|
|
138
|
+
prefix = prefix.slice(0, -1);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
129
142
|
|
|
130
143
|
document.getElementById("token").value = token;
|
|
131
144
|
document.getElementById("returnUrl").value = returnUrl;
|
|
145
|
+
document.getElementById("prefix").value = prefix;
|
|
132
146
|
|
|
133
147
|
document.getElementById("resetForm").addEventListener("submit", async function (event) {
|
|
134
148
|
event.preventDefault();
|
|
@@ -154,7 +168,7 @@
|
|
|
154
168
|
|
|
155
169
|
// Effettua la richiesta API
|
|
156
170
|
try {
|
|
157
|
-
const response = await fetch(
|
|
171
|
+
const response = await fetch(`${prefix}/api/accessi/auth/confirm-reset-password/${token}`, {
|
|
158
172
|
method: "POST",
|
|
159
173
|
headers: { "Content-Type": "application/json" },
|
|
160
174
|
body: JSON.stringify({ newPassword: password })
|
|
@@ -162,23 +176,16 @@
|
|
|
162
176
|
|
|
163
177
|
const data = await response.json();
|
|
164
178
|
alert(data.message || "Password aggiornata con successo!");
|
|
165
|
-
|
|
166
|
-
|
|
167
179
|
} catch (error) {
|
|
168
180
|
alert("Errore nel reset della password. Riprova più tardi.");
|
|
169
|
-
}
|
|
170
|
-
finally {
|
|
171
|
-
|
|
181
|
+
} finally {
|
|
172
182
|
setTimeout(() => {
|
|
173
|
-
|
|
174
183
|
if (returnUrl.startsWith("https://") || returnUrl.startsWith("http://")) {
|
|
175
184
|
window.location.href = returnUrl;
|
|
176
185
|
} else {
|
|
177
186
|
window.location.href = "https://" + returnUrl;
|
|
178
187
|
}
|
|
179
|
-
|
|
180
188
|
}, 500);
|
|
181
|
-
|
|
182
189
|
}
|
|
183
190
|
});
|
|
184
191
|
});
|