emilsoftware-utilities 1.4.0-dev.3 → 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/Controllers/EmailController.js +1 -1
- package/dist/accessi-module/Services/AuthService/AuthService.js +1 -1
- package/dist/accessi-module/Services/EmailService/EmailService.d.ts +0 -2
- package/dist/accessi-module/Services/EmailService/EmailService.js +2 -6
- 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.3.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);
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { AccessiOptions } from '../../AccessiModule';
|
|
2
|
-
import { Logger } from '../../../Logger';
|
|
3
2
|
export declare class EmailService {
|
|
4
3
|
private readonly accessiOptions;
|
|
5
|
-
logger: Logger;
|
|
6
4
|
constructor(accessiOptions: AccessiOptions);
|
|
7
5
|
sendAccountUpdateEmail(email: string, message: string): Promise<void>;
|
|
8
6
|
private transporter;
|
|
@@ -23,7 +23,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
23
23
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
24
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
25
|
};
|
|
26
|
-
var EmailService_1;
|
|
27
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
27
|
exports.EmailService = void 0;
|
|
29
28
|
const nodemailer_1 = __importDefault(require("nodemailer"));
|
|
@@ -31,11 +30,9 @@ const uuid_1 = require("uuid");
|
|
|
31
30
|
const Orm_1 = require("../../../Orm");
|
|
32
31
|
const common_1 = require("@nestjs/common");
|
|
33
32
|
const StatoRegistrazione_1 = require("../../Dtos/StatoRegistrazione");
|
|
34
|
-
|
|
35
|
-
let EmailService = EmailService_1 = class EmailService {
|
|
33
|
+
let EmailService = class EmailService {
|
|
36
34
|
constructor(accessiOptions) {
|
|
37
35
|
this.accessiOptions = accessiOptions;
|
|
38
|
-
this.logger = new Logger_1.Logger(EmailService_1.name);
|
|
39
36
|
this.transporter = nodemailer_1.default.createTransport(this.accessiOptions.emailOptions);
|
|
40
37
|
}
|
|
41
38
|
sendAccountUpdateEmail(email, message) {
|
|
@@ -56,7 +53,6 @@ let EmailService = EmailService_1 = class EmailService {
|
|
|
56
53
|
let resetUrl = `${confirmationEmailUrl}/api/accessi/email/reset-password-page/${resetToken}${returnUrlQueryParams}`;
|
|
57
54
|
if (resetUrlCustom) {
|
|
58
55
|
resetUrl = resetUrlCustom + "?token=" + resetToken;
|
|
59
|
-
this.logger.info('url personalizzato: ', resetUrl);
|
|
60
56
|
}
|
|
61
57
|
let sPhrase;
|
|
62
58
|
if (htmlMail) {
|
|
@@ -358,7 +354,7 @@ let EmailService = EmailService_1 = class EmailService {
|
|
|
358
354
|
}
|
|
359
355
|
};
|
|
360
356
|
exports.EmailService = EmailService;
|
|
361
|
-
exports.EmailService = EmailService =
|
|
357
|
+
exports.EmailService = EmailService = __decorate([
|
|
362
358
|
(0, common_1.Injectable)(),
|
|
363
359
|
__param(0, (0, common_1.Inject)('ACCESSI_OPTIONS')),
|
|
364
360
|
__metadata("design:paramtypes", [Object])
|
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|