emilsoftware-utilities 1.4.0-dev.4 → 1.4.0-dev.5
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/Utilities.d.ts +1 -0
- package/dist/Utilities.js +8 -0
- package/dist/accessi-module/Controllers/AuthController.js +18 -0
- package/dist/accessi-module/Services/AuthService/AuthService.js +1 -1
- package/dist/emilsoftware-utilities-1.4.0-dev.5.tgz +0 -0
- package/package.json +1 -1
- package/dist/emilsoftware-utilities-1.4.0-dev.4.tgz +0 -0
package/dist/Utilities.d.ts
CHANGED
|
@@ -64,6 +64,7 @@ export declare class RestUtilities {
|
|
|
64
64
|
static sendErrorMessage(res: Response, error: any, tag?: string, status?: number): Response;
|
|
65
65
|
static sendUnauthorized(res: Response): Response;
|
|
66
66
|
static sendInvalidCredentials(res: Response): Response;
|
|
67
|
+
static sendPasswordExpired(res: Response): Response;
|
|
67
68
|
/**
|
|
68
69
|
* Sends a base response with a payload.
|
|
69
70
|
* @param res - Express Response object.
|
package/dist/Utilities.js
CHANGED
|
@@ -138,6 +138,14 @@ class RestUtilities {
|
|
|
138
138
|
message: "Credenziali non valide"
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
|
+
static sendPasswordExpired(res) {
|
|
142
|
+
return res.status(403).send({
|
|
143
|
+
severity: "warning",
|
|
144
|
+
statusCode: StatusCode.Warning,
|
|
145
|
+
code: "PASSWORD_EXPIRED",
|
|
146
|
+
message: "Password scaduta. E' necessario aggiornarla"
|
|
147
|
+
});
|
|
148
|
+
}
|
|
141
149
|
/**
|
|
142
150
|
* Sends a base response with a payload.
|
|
143
151
|
* @param res - Express Response object.
|
|
@@ -112,6 +112,10 @@ let AuthController = AuthController_1 = class AuthController {
|
|
|
112
112
|
return Utilities_1.RestUtilities.sendBaseResponse(res, userData);
|
|
113
113
|
}
|
|
114
114
|
catch (error) {
|
|
115
|
+
if (error.message === 'PASSWORD_EXPIRED') {
|
|
116
|
+
this.logger.warning('Password scaduta, cambiare password ', error);
|
|
117
|
+
return Utilities_1.RestUtilities.sendPasswordExpired(res);
|
|
118
|
+
}
|
|
115
119
|
this.logger.error('Errore durante il login', error);
|
|
116
120
|
return Utilities_1.RestUtilities.sendInvalidCredentials(res);
|
|
117
121
|
}
|
|
@@ -161,6 +165,20 @@ __decorate([
|
|
|
161
165
|
status: 401,
|
|
162
166
|
description: 'Credenziali non valide',
|
|
163
167
|
}),
|
|
168
|
+
(0, swagger_1.ApiResponse)({
|
|
169
|
+
status: 403,
|
|
170
|
+
description: "Password scaduta, è necessatio aggiornarla. ",
|
|
171
|
+
schema: {
|
|
172
|
+
example: {
|
|
173
|
+
message: {
|
|
174
|
+
severity: 'warning',
|
|
175
|
+
statusCode: 2, // o il valore di StatusCode.Warning
|
|
176
|
+
code: 'PASSWORD_EXPIRED',
|
|
177
|
+
message: 'Password scaduta. È necessario aggiornarla.',
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}),
|
|
164
182
|
(0, common_1.Post)('login'),
|
|
165
183
|
__param(0, (0, common_1.Body)()),
|
|
166
184
|
__param(1, (0, common_1.Res)()),
|
|
@@ -64,7 +64,7 @@ let AuthService = class AuthService {
|
|
|
64
64
|
const today = new Date();
|
|
65
65
|
const targetDate = new Date(utente.dataScadenzaPassword);
|
|
66
66
|
if (today >= targetDate) {
|
|
67
|
-
throw new Error("
|
|
67
|
+
throw new Error("PASSWORD_EXPIRED");
|
|
68
68
|
}
|
|
69
69
|
// Recupera i grants
|
|
70
70
|
const userGrants = yield this.permissionService.getUserRolesAndGrants(utente.codiceUtente);
|
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|