@flusys/nestjs-auth 1.0.0-beta → 1.0.0
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/README.md +590 -473
- package/cjs/config/auth.constants.js +12 -0
- package/cjs/controllers/authentication.controller.js +365 -24
- package/cjs/controllers/branch.controller.js +44 -1
- package/cjs/controllers/company-selection.controller.js +27 -20
- package/cjs/controllers/company.controller.js +44 -1
- package/cjs/controllers/user-permission.controller.js +82 -154
- package/cjs/controllers/user.controller.js +211 -7
- package/cjs/docs/auth-swagger.config.js +14 -7
- package/cjs/dtos/authentication.dto.js +114 -38
- package/cjs/dtos/index.js +0 -1
- package/cjs/dtos/user-permission.dto.js +28 -0
- package/cjs/dtos/user.dto.js +19 -4
- package/cjs/entities/index.js +5 -1
- package/cjs/entities/pending-registration.entity.js +125 -0
- package/cjs/entities/user-company-permission.entity.js +3 -9
- package/cjs/entities/user-token.entity.js +129 -0
- package/cjs/interceptors/clear-token.interceptor.js +10 -23
- package/cjs/interceptors/set-token.interceptor.js +15 -55
- package/cjs/interfaces/auth-email-provider.interface.js +45 -0
- package/cjs/interfaces/index.js +2 -0
- package/cjs/interfaces/user-enricher.interface.js +4 -0
- package/cjs/modules/auth.module.js +65 -143
- package/cjs/services/auth-config.service.js +25 -27
- package/cjs/services/auth-datasource.provider.js +13 -23
- package/cjs/services/auth-email.service.js +456 -0
- package/cjs/services/authentication.service.js +297 -349
- package/cjs/services/branch.service.js +9 -4
- package/cjs/services/company-selection-session.service.js +1 -1
- package/cjs/services/index.js +1 -0
- package/cjs/services/user-permission.service.js +43 -73
- package/cjs/services/user.service.js +184 -34
- package/cjs/strategies/jwt.strategy.js +44 -44
- package/cjs/validators/password.validator.js +45 -0
- package/config/auth.constants.d.ts +3 -0
- package/controllers/authentication.controller.d.ts +16 -10
- package/controllers/company-selection.controller.d.ts +6 -2
- package/controllers/user-permission.controller.d.ts +5 -4
- package/controllers/user.controller.d.ts +33 -0
- package/dtos/authentication.dto.d.ts +20 -6
- package/dtos/company-branch.dto.d.ts +0 -1
- package/dtos/company.dto.d.ts +0 -1
- package/dtos/index.d.ts +0 -1
- package/dtos/user-permission.dto.d.ts +4 -0
- package/dtos/user.dto.d.ts +1 -2
- package/entities/index.d.ts +7 -3
- package/entities/pending-registration.entity.d.ts +17 -0
- package/entities/user-company-permission.entity.d.ts +1 -3
- package/entities/user-token.entity.d.ts +15 -0
- package/fesm/config/auth.constants.js +6 -2
- package/fesm/controllers/authentication.controller.js +368 -27
- package/fesm/controllers/branch.controller.js +45 -2
- package/fesm/controllers/company-selection.controller.js +28 -21
- package/fesm/controllers/company.controller.js +45 -2
- package/fesm/controllers/user-permission.controller.js +84 -156
- package/fesm/controllers/user.controller.js +214 -10
- package/fesm/docs/auth-swagger.config.js +14 -7
- package/fesm/dtos/authentication.dto.js +101 -39
- package/fesm/dtos/index.js +0 -1
- package/fesm/dtos/user-permission.dto.js +28 -0
- package/fesm/dtos/user.dto.js +20 -5
- package/fesm/entities/index.js +7 -1
- package/fesm/entities/pending-registration.entity.js +115 -0
- package/fesm/entities/user-company-permission.entity.js +3 -9
- package/fesm/entities/user-token.entity.js +113 -0
- package/fesm/interceptors/clear-token.interceptor.js +9 -22
- package/fesm/interceptors/set-token.interceptor.js +14 -54
- package/fesm/interfaces/auth-email-provider.interface.js +38 -0
- package/fesm/interfaces/authentication.interface.js +1 -1
- package/fesm/interfaces/index.js +2 -0
- package/fesm/interfaces/user-enricher.interface.js +26 -0
- package/fesm/modules/auth.module.js +67 -145
- package/fesm/services/auth-config.service.js +26 -28
- package/fesm/services/auth-datasource.provider.js +14 -24
- package/fesm/services/auth-email.service.js +405 -0
- package/fesm/services/authentication.service.js +297 -349
- package/fesm/services/branch.service.js +9 -4
- package/fesm/services/company-selection-session.service.js +1 -1
- package/fesm/services/index.js +1 -0
- package/fesm/services/user-permission.service.js +44 -74
- package/fesm/services/user.service.js +186 -36
- package/fesm/strategies/jwt.strategy.js +44 -44
- package/fesm/validators/password.validator.js +48 -0
- package/interceptors/clear-token.interceptor.d.ts +0 -1
- package/interceptors/set-token.interceptor.d.ts +1 -1
- package/interfaces/auth-email-provider.interface.d.ts +6 -0
- package/interfaces/auth-module-options.interface.d.ts +4 -1
- package/interfaces/authentication.interface.d.ts +13 -3
- package/interfaces/index.d.ts +2 -0
- package/interfaces/user-enricher.interface.d.ts +64 -0
- package/interfaces/user.interface.d.ts +1 -0
- package/modules/auth.module.d.ts +6 -3
- package/package.json +4 -4
- package/services/auth-config.service.d.ts +7 -8
- package/services/auth-datasource.provider.d.ts +2 -4
- package/services/auth-email.service.d.ts +54 -0
- package/services/authentication.service.d.ts +27 -16
- package/services/company-selection-session.service.d.ts +1 -1
- package/services/index.d.ts +1 -0
- package/services/user-permission.service.d.ts +6 -9
- package/services/user.service.d.ts +19 -3
- package/strategies/jwt.strategy.d.ts +4 -1
- package/validators/password.validator.d.ts +10 -0
- package/cjs/dtos/user-company-permission.dto.js +0 -110
- package/dtos/user-company-permission.dto.d.ts +0 -10
- package/fesm/dtos/user-company-permission.dto.js +0 -98
|
@@ -14,6 +14,16 @@ Object.defineProperty(exports, "authSwaggerConfig", {
|
|
|
14
14
|
'User Permissions',
|
|
15
15
|
'Company Selection'
|
|
16
16
|
];
|
|
17
|
+
/** Examples to exclude when company feature is disabled */ const COMPANY_EXAMPLE_EXCLUSIONS = [
|
|
18
|
+
{
|
|
19
|
+
pathPattern: '/auth/login',
|
|
20
|
+
method: 'post',
|
|
21
|
+
examples: [
|
|
22
|
+
'loginSuccessWithCompany',
|
|
23
|
+
'companySelection'
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
];
|
|
17
27
|
/**
|
|
18
28
|
* Schema properties to exclude when company feature is disabled
|
|
19
29
|
*
|
|
@@ -58,16 +68,14 @@ Object.defineProperty(exports, "authSwaggerConfig", {
|
|
|
58
68
|
schemaName: 'RegistrationResponseDto',
|
|
59
69
|
properties: [
|
|
60
70
|
'company',
|
|
61
|
-
'branch'
|
|
62
|
-
'companyFeatureEnabled'
|
|
71
|
+
'branch'
|
|
63
72
|
]
|
|
64
73
|
},
|
|
65
74
|
{
|
|
66
75
|
schemaName: 'LoginResponseDto',
|
|
67
76
|
properties: [
|
|
68
77
|
'company',
|
|
69
|
-
'branch'
|
|
70
|
-
'companyFeatureEnabled'
|
|
78
|
+
'branch'
|
|
71
79
|
]
|
|
72
80
|
},
|
|
73
81
|
{
|
|
@@ -102,7 +110,6 @@ Object.defineProperty(exports, "authSwaggerConfig", {
|
|
|
102
110
|
'id',
|
|
103
111
|
'name',
|
|
104
112
|
'slug',
|
|
105
|
-
'isActive',
|
|
106
113
|
'logoId'
|
|
107
114
|
]
|
|
108
115
|
},
|
|
@@ -112,7 +119,6 @@ Object.defineProperty(exports, "authSwaggerConfig", {
|
|
|
112
119
|
'id',
|
|
113
120
|
'name',
|
|
114
121
|
'slug',
|
|
115
|
-
'isActive',
|
|
116
122
|
'logoId',
|
|
117
123
|
'branches'
|
|
118
124
|
]
|
|
@@ -404,6 +410,7 @@ POST /auth/login → { accessToken, refreshToken, user }
|
|
|
404
410
|
path: 'api/docs/auth',
|
|
405
411
|
bearerAuth: true,
|
|
406
412
|
excludeTags,
|
|
407
|
-
excludeSchemaProperties: enableCompanyFeature ? undefined : COMPANY_SCHEMA_EXCLUSIONS
|
|
413
|
+
excludeSchemaProperties: enableCompanyFeature ? undefined : COMPANY_SCHEMA_EXCLUSIONS,
|
|
414
|
+
excludeExamples: enableCompanyFeature ? undefined : COMPANY_EXAMPLE_EXCLUSIONS
|
|
408
415
|
};
|
|
409
416
|
}
|
|
@@ -27,12 +27,18 @@ _export(exports, {
|
|
|
27
27
|
get CompanyWithBranchesDto () {
|
|
28
28
|
return CompanyWithBranchesDto;
|
|
29
29
|
},
|
|
30
|
+
get ForgotPasswordDto () {
|
|
31
|
+
return ForgotPasswordDto;
|
|
32
|
+
},
|
|
30
33
|
get LoginDto () {
|
|
31
34
|
return LoginDto;
|
|
32
35
|
},
|
|
33
36
|
get LoginResponseDto () {
|
|
34
37
|
return LoginResponseDto;
|
|
35
38
|
},
|
|
39
|
+
get LoginResponseRequiresEmailVerificationDto () {
|
|
40
|
+
return LoginResponseRequiresEmailVerificationDto;
|
|
41
|
+
},
|
|
36
42
|
get MeResponseDto () {
|
|
37
43
|
return MeResponseDto;
|
|
38
44
|
},
|
|
@@ -45,6 +51,12 @@ _export(exports, {
|
|
|
45
51
|
get RegistrationResponseDto () {
|
|
46
52
|
return RegistrationResponseDto;
|
|
47
53
|
},
|
|
54
|
+
get ResendVerificationDto () {
|
|
55
|
+
return ResendVerificationDto;
|
|
56
|
+
},
|
|
57
|
+
get ResetPasswordDto () {
|
|
58
|
+
return ResetPasswordDto;
|
|
59
|
+
},
|
|
48
60
|
get SelectDto () {
|
|
49
61
|
return SelectDto;
|
|
50
62
|
},
|
|
@@ -53,10 +65,14 @@ _export(exports, {
|
|
|
53
65
|
},
|
|
54
66
|
get UserInfoDto () {
|
|
55
67
|
return UserInfoDto;
|
|
68
|
+
},
|
|
69
|
+
get VerifyEmailDto () {
|
|
70
|
+
return VerifyEmailDto;
|
|
56
71
|
}
|
|
57
72
|
});
|
|
58
73
|
const _swagger = require("@nestjs/swagger");
|
|
59
74
|
const _classvalidator = require("class-validator");
|
|
75
|
+
const _passwordvalidator = require("../validators/password.validator");
|
|
60
76
|
function _define_property(obj, key, value) {
|
|
61
77
|
if (key in obj) {
|
|
62
78
|
Object.defineProperty(obj, key, {
|
|
@@ -96,12 +112,12 @@ _ts_decorate([
|
|
|
96
112
|
], LoginDto.prototype, "email", void 0);
|
|
97
113
|
_ts_decorate([
|
|
98
114
|
(0, _swagger.ApiProperty)({
|
|
99
|
-
example: '
|
|
100
|
-
description: 'User password
|
|
115
|
+
example: 'SecureP@ss1',
|
|
116
|
+
description: 'User password'
|
|
101
117
|
}),
|
|
102
118
|
(0, _classvalidator.IsString)(),
|
|
103
119
|
(0, _classvalidator.IsNotEmpty)(),
|
|
104
|
-
(0, _classvalidator.
|
|
120
|
+
(0, _classvalidator.MaxLength)(128),
|
|
105
121
|
_ts_metadata("design:type", String)
|
|
106
122
|
], LoginDto.prototype, "password", void 0);
|
|
107
123
|
let RegistrationDto = class RegistrationDto {
|
|
@@ -140,13 +156,13 @@ _ts_decorate([
|
|
|
140
156
|
], RegistrationDto.prototype, "email", void 0);
|
|
141
157
|
_ts_decorate([
|
|
142
158
|
(0, _swagger.ApiProperty)({
|
|
143
|
-
example: '
|
|
144
|
-
description: 'Password (min
|
|
159
|
+
example: 'StrongP@ss123',
|
|
160
|
+
description: 'Password (min 8 chars, requires uppercase, lowercase, number, special char)'
|
|
145
161
|
}),
|
|
146
162
|
(0, _classvalidator.IsNotEmpty)(),
|
|
147
163
|
(0, _classvalidator.IsString)(),
|
|
148
|
-
(0,
|
|
149
|
-
(0, _classvalidator.MaxLength)(
|
|
164
|
+
(0, _passwordvalidator.IsStrongPassword)(),
|
|
165
|
+
(0, _classvalidator.MaxLength)(128),
|
|
150
166
|
_ts_metadata("design:type", String)
|
|
151
167
|
], RegistrationDto.prototype, "password", void 0);
|
|
152
168
|
_ts_decorate([
|
|
@@ -207,6 +223,7 @@ _ts_decorate([
|
|
|
207
223
|
}),
|
|
208
224
|
(0, _classvalidator.IsOptional)(),
|
|
209
225
|
(0, _classvalidator.IsString)(),
|
|
226
|
+
(0, _classvalidator.MaxLength)(500),
|
|
210
227
|
_ts_metadata("design:type", String)
|
|
211
228
|
], RegistrationDto.prototype, "newCompanyAddress", void 0);
|
|
212
229
|
let RefreshTokenDto = class RefreshTokenDto {
|
|
@@ -236,16 +253,17 @@ _ts_decorate([
|
|
|
236
253
|
}),
|
|
237
254
|
(0, _classvalidator.IsString)(),
|
|
238
255
|
(0, _classvalidator.IsNotEmpty)(),
|
|
256
|
+
(0, _classvalidator.MaxLength)(128),
|
|
239
257
|
_ts_metadata("design:type", String)
|
|
240
258
|
], ChangePasswordDto.prototype, "currentPassword", void 0);
|
|
241
259
|
_ts_decorate([
|
|
242
260
|
(0, _swagger.ApiProperty)({
|
|
243
|
-
example: '
|
|
244
|
-
description: 'New password (min
|
|
261
|
+
example: 'NewP@ssword456',
|
|
262
|
+
description: 'New password (min 8 chars, requires uppercase, lowercase, number, special char)'
|
|
245
263
|
}),
|
|
246
264
|
(0, _classvalidator.IsString)(),
|
|
247
265
|
(0, _classvalidator.IsNotEmpty)(),
|
|
248
|
-
(0,
|
|
266
|
+
(0, _passwordvalidator.IsStrongPassword)(),
|
|
249
267
|
_ts_metadata("design:type", String)
|
|
250
268
|
], ChangePasswordDto.prototype, "newPassword", void 0);
|
|
251
269
|
let SelectDto = class SelectDto {
|
|
@@ -413,7 +431,6 @@ let BranchSelectionInfoDto = class BranchSelectionInfoDto {
|
|
|
413
431
|
_define_property(this, "id", void 0);
|
|
414
432
|
_define_property(this, "name", void 0);
|
|
415
433
|
_define_property(this, "slug", void 0);
|
|
416
|
-
_define_property(this, "isActive", void 0);
|
|
417
434
|
_define_property(this, "logoId", void 0);
|
|
418
435
|
}
|
|
419
436
|
};
|
|
@@ -435,12 +452,6 @@ _ts_decorate([
|
|
|
435
452
|
}),
|
|
436
453
|
_ts_metadata("design:type", String)
|
|
437
454
|
], BranchSelectionInfoDto.prototype, "slug", void 0);
|
|
438
|
-
_ts_decorate([
|
|
439
|
-
(0, _swagger.ApiProperty)({
|
|
440
|
-
example: true
|
|
441
|
-
}),
|
|
442
|
-
_ts_metadata("design:type", Boolean)
|
|
443
|
-
], BranchSelectionInfoDto.prototype, "isActive", void 0);
|
|
444
455
|
_ts_decorate([
|
|
445
456
|
(0, _swagger.ApiPropertyOptional)({
|
|
446
457
|
example: '550e8400-e29b-41d4-a716-446655440077',
|
|
@@ -454,7 +465,6 @@ let CompanyWithBranchesDto = class CompanyWithBranchesDto {
|
|
|
454
465
|
_define_property(this, "id", void 0);
|
|
455
466
|
_define_property(this, "name", void 0);
|
|
456
467
|
_define_property(this, "slug", void 0);
|
|
457
|
-
_define_property(this, "isActive", void 0);
|
|
458
468
|
_define_property(this, "logoId", void 0);
|
|
459
469
|
_define_property(this, "branches", void 0);
|
|
460
470
|
}
|
|
@@ -477,12 +487,6 @@ _ts_decorate([
|
|
|
477
487
|
}),
|
|
478
488
|
_ts_metadata("design:type", String)
|
|
479
489
|
], CompanyWithBranchesDto.prototype, "slug", void 0);
|
|
480
|
-
_ts_decorate([
|
|
481
|
-
(0, _swagger.ApiProperty)({
|
|
482
|
-
example: true
|
|
483
|
-
}),
|
|
484
|
-
_ts_metadata("design:type", Boolean)
|
|
485
|
-
], CompanyWithBranchesDto.prototype, "isActive", void 0);
|
|
486
490
|
_ts_decorate([
|
|
487
491
|
(0, _swagger.ApiPropertyOptional)({
|
|
488
492
|
example: '550e8400-e29b-41d4-a716-446655440088',
|
|
@@ -507,7 +511,6 @@ let LoginResponseDto = class LoginResponseDto {
|
|
|
507
511
|
_define_property(this, "user", void 0);
|
|
508
512
|
_define_property(this, "company", void 0);
|
|
509
513
|
_define_property(this, "branch", void 0);
|
|
510
|
-
_define_property(this, "companyFeatureEnabled", void 0);
|
|
511
514
|
}
|
|
512
515
|
};
|
|
513
516
|
_ts_decorate([
|
|
@@ -543,13 +546,6 @@ _ts_decorate([
|
|
|
543
546
|
}),
|
|
544
547
|
_ts_metadata("design:type", typeof BranchInfoDto === "undefined" ? Object : BranchInfoDto)
|
|
545
548
|
], LoginResponseDto.prototype, "branch", void 0);
|
|
546
|
-
_ts_decorate([
|
|
547
|
-
(0, _swagger.ApiPropertyOptional)({
|
|
548
|
-
example: true,
|
|
549
|
-
description: 'Whether company feature is enabled'
|
|
550
|
-
}),
|
|
551
|
-
_ts_metadata("design:type", Boolean)
|
|
552
|
-
], LoginResponseDto.prototype, "companyFeatureEnabled", void 0);
|
|
553
549
|
let RegistrationResponseDto = class RegistrationResponseDto {
|
|
554
550
|
constructor(){
|
|
555
551
|
_define_property(this, "accessToken", void 0);
|
|
@@ -557,17 +553,17 @@ let RegistrationResponseDto = class RegistrationResponseDto {
|
|
|
557
553
|
_define_property(this, "user", void 0);
|
|
558
554
|
_define_property(this, "company", void 0);
|
|
559
555
|
_define_property(this, "branch", void 0);
|
|
560
|
-
_define_property(this, "
|
|
556
|
+
_define_property(this, "requiresEmailVerification", void 0);
|
|
561
557
|
}
|
|
562
558
|
};
|
|
563
559
|
_ts_decorate([
|
|
564
|
-
(0, _swagger.
|
|
560
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
565
561
|
example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
|
|
566
562
|
}),
|
|
567
563
|
_ts_metadata("design:type", String)
|
|
568
564
|
], RegistrationResponseDto.prototype, "accessToken", void 0);
|
|
569
565
|
_ts_decorate([
|
|
570
|
-
(0, _swagger.
|
|
566
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
571
567
|
example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
|
|
572
568
|
}),
|
|
573
569
|
_ts_metadata("design:type", String)
|
|
@@ -594,12 +590,12 @@ _ts_decorate([
|
|
|
594
590
|
_ts_metadata("design:type", typeof BranchInfoDto === "undefined" ? Object : BranchInfoDto)
|
|
595
591
|
], RegistrationResponseDto.prototype, "branch", void 0);
|
|
596
592
|
_ts_decorate([
|
|
597
|
-
(0, _swagger.
|
|
593
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
598
594
|
example: true,
|
|
599
|
-
description: 'Whether
|
|
595
|
+
description: 'Whether email verification is required'
|
|
600
596
|
}),
|
|
601
597
|
_ts_metadata("design:type", Boolean)
|
|
602
|
-
], RegistrationResponseDto.prototype, "
|
|
598
|
+
], RegistrationResponseDto.prototype, "requiresEmailVerification", void 0);
|
|
603
599
|
let MeResponseDto = class MeResponseDto {
|
|
604
600
|
constructor(){
|
|
605
601
|
_define_property(this, "user", void 0);
|
|
@@ -674,3 +670,83 @@ _ts_decorate([
|
|
|
674
670
|
}),
|
|
675
671
|
_ts_metadata("design:type", Array)
|
|
676
672
|
], CompanySelectionResponseDto.prototype, "companies", void 0);
|
|
673
|
+
let LoginResponseRequiresEmailVerificationDto = class LoginResponseRequiresEmailVerificationDto {
|
|
674
|
+
constructor(){
|
|
675
|
+
_define_property(this, "requiresEmailVerification", void 0);
|
|
676
|
+
_define_property(this, "email", void 0);
|
|
677
|
+
_define_property(this, "message", void 0);
|
|
678
|
+
}
|
|
679
|
+
};
|
|
680
|
+
_ts_decorate([
|
|
681
|
+
(0, _swagger.ApiProperty)({
|
|
682
|
+
example: true
|
|
683
|
+
}),
|
|
684
|
+
_ts_metadata("design:type", Boolean)
|
|
685
|
+
], LoginResponseRequiresEmailVerificationDto.prototype, "requiresEmailVerification", void 0);
|
|
686
|
+
_ts_decorate([
|
|
687
|
+
(0, _swagger.ApiProperty)({
|
|
688
|
+
example: 'john@example.com'
|
|
689
|
+
}),
|
|
690
|
+
_ts_metadata("design:type", String)
|
|
691
|
+
], LoginResponseRequiresEmailVerificationDto.prototype, "email", void 0);
|
|
692
|
+
_ts_decorate([
|
|
693
|
+
(0, _swagger.ApiProperty)({
|
|
694
|
+
example: 'Please verify your email address before logging in.'
|
|
695
|
+
}),
|
|
696
|
+
_ts_metadata("design:type", String)
|
|
697
|
+
], LoginResponseRequiresEmailVerificationDto.prototype, "message", void 0);
|
|
698
|
+
let ForgotPasswordDto = class ForgotPasswordDto {
|
|
699
|
+
constructor(){
|
|
700
|
+
_define_property(this, "email", void 0);
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
_ts_decorate([
|
|
704
|
+
(0, _swagger.ApiProperty)({
|
|
705
|
+
example: 'john@example.com',
|
|
706
|
+
description: 'Email address to send reset link to'
|
|
707
|
+
}),
|
|
708
|
+
(0, _classvalidator.IsEmail)(),
|
|
709
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
710
|
+
_ts_metadata("design:type", String)
|
|
711
|
+
], ForgotPasswordDto.prototype, "email", void 0);
|
|
712
|
+
let ResetPasswordDto = class ResetPasswordDto {
|
|
713
|
+
constructor(){
|
|
714
|
+
_define_property(this, "token", void 0);
|
|
715
|
+
_define_property(this, "newPassword", void 0);
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
_ts_decorate([
|
|
719
|
+
(0, _swagger.ApiProperty)({
|
|
720
|
+
example: 'a1b2c3d4e5f6...',
|
|
721
|
+
description: 'Password reset token from email'
|
|
722
|
+
}),
|
|
723
|
+
(0, _classvalidator.IsString)(),
|
|
724
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
725
|
+
_ts_metadata("design:type", String)
|
|
726
|
+
], ResetPasswordDto.prototype, "token", void 0);
|
|
727
|
+
_ts_decorate([
|
|
728
|
+
(0, _swagger.ApiProperty)({
|
|
729
|
+
example: 'NewSecureP@ss123',
|
|
730
|
+
description: 'New password (min 8 chars, requires uppercase, lowercase, number, special char)'
|
|
731
|
+
}),
|
|
732
|
+
(0, _classvalidator.IsString)(),
|
|
733
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
734
|
+
(0, _passwordvalidator.IsStrongPassword)(),
|
|
735
|
+
_ts_metadata("design:type", String)
|
|
736
|
+
], ResetPasswordDto.prototype, "newPassword", void 0);
|
|
737
|
+
let VerifyEmailDto = class VerifyEmailDto {
|
|
738
|
+
constructor(){
|
|
739
|
+
_define_property(this, "token", void 0);
|
|
740
|
+
}
|
|
741
|
+
};
|
|
742
|
+
_ts_decorate([
|
|
743
|
+
(0, _swagger.ApiProperty)({
|
|
744
|
+
example: 'a1b2c3d4e5f6...',
|
|
745
|
+
description: 'Email verification token from email'
|
|
746
|
+
}),
|
|
747
|
+
(0, _classvalidator.IsString)(),
|
|
748
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
749
|
+
_ts_metadata("design:type", String)
|
|
750
|
+
], VerifyEmailDto.prototype, "token", void 0);
|
|
751
|
+
let ResendVerificationDto = class ResendVerificationDto extends ForgotPasswordDto {
|
|
752
|
+
};
|
package/cjs/dtos/index.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
_export_star(require("./authentication.dto"), exports);
|
|
6
6
|
_export_star(require("./company-branch.dto"), exports);
|
|
7
7
|
_export_star(require("./company.dto"), exports);
|
|
8
|
-
_export_star(require("./user-company-permission.dto"), exports);
|
|
9
8
|
_export_star(require("./user.dto"), exports);
|
|
10
9
|
_export_star(require("./user-permission.dto"), exports);
|
|
11
10
|
function _export_star(from, to) {
|
|
@@ -254,9 +254,23 @@ _ts_decorate([
|
|
|
254
254
|
], UserBranchPermissionDto.prototype, "companyId", void 0);
|
|
255
255
|
let UserCompaniesResponseDto = class UserCompaniesResponseDto {
|
|
256
256
|
constructor(){
|
|
257
|
+
_define_property(this, "success", void 0);
|
|
258
|
+
_define_property(this, "message", void 0);
|
|
257
259
|
_define_property(this, "data", void 0);
|
|
258
260
|
}
|
|
259
261
|
};
|
|
262
|
+
_ts_decorate([
|
|
263
|
+
(0, _swagger.ApiProperty)({
|
|
264
|
+
example: true
|
|
265
|
+
}),
|
|
266
|
+
_ts_metadata("design:type", Boolean)
|
|
267
|
+
], UserCompaniesResponseDto.prototype, "success", void 0);
|
|
268
|
+
_ts_decorate([
|
|
269
|
+
(0, _swagger.ApiProperty)({
|
|
270
|
+
example: 'User companies retrieved successfully'
|
|
271
|
+
}),
|
|
272
|
+
_ts_metadata("design:type", String)
|
|
273
|
+
], UserCompaniesResponseDto.prototype, "message", void 0);
|
|
260
274
|
_ts_decorate([
|
|
261
275
|
(0, _swagger.ApiProperty)({
|
|
262
276
|
description: 'List of companies the user has access to',
|
|
@@ -284,9 +298,23 @@ _ts_decorate([
|
|
|
284
298
|
], UserCompaniesResponseDto.prototype, "data", void 0);
|
|
285
299
|
let UserBranchesResponseDto = class UserBranchesResponseDto {
|
|
286
300
|
constructor(){
|
|
301
|
+
_define_property(this, "success", void 0);
|
|
302
|
+
_define_property(this, "message", void 0);
|
|
287
303
|
_define_property(this, "data", void 0);
|
|
288
304
|
}
|
|
289
305
|
};
|
|
306
|
+
_ts_decorate([
|
|
307
|
+
(0, _swagger.ApiProperty)({
|
|
308
|
+
example: true
|
|
309
|
+
}),
|
|
310
|
+
_ts_metadata("design:type", Boolean)
|
|
311
|
+
], UserBranchesResponseDto.prototype, "success", void 0);
|
|
312
|
+
_ts_decorate([
|
|
313
|
+
(0, _swagger.ApiProperty)({
|
|
314
|
+
example: 'User branches retrieved successfully'
|
|
315
|
+
}),
|
|
316
|
+
_ts_metadata("design:type", String)
|
|
317
|
+
], UserBranchesResponseDto.prototype, "message", void 0);
|
|
290
318
|
_ts_decorate([
|
|
291
319
|
(0, _swagger.ApiProperty)({
|
|
292
320
|
description: 'List of branches the user has access to',
|
package/cjs/dtos/user.dto.js
CHANGED
|
@@ -21,6 +21,7 @@ _export(exports, {
|
|
|
21
21
|
});
|
|
22
22
|
const _swagger = require("@nestjs/swagger");
|
|
23
23
|
const _classvalidator = require("class-validator");
|
|
24
|
+
const _passwordvalidator = require("../validators/password.validator");
|
|
24
25
|
function _define_property(obj, key, value) {
|
|
25
26
|
if (key in obj) {
|
|
26
27
|
Object.defineProperty(obj, key, {
|
|
@@ -83,10 +84,13 @@ _ts_decorate([
|
|
|
83
84
|
], CreateUserDto.prototype, "email", void 0);
|
|
84
85
|
_ts_decorate([
|
|
85
86
|
(0, _swagger.ApiProperty)({
|
|
86
|
-
example: '
|
|
87
|
-
description: 'Password'
|
|
87
|
+
example: 'SecureP@ss123',
|
|
88
|
+
description: 'Password (must meet complexity requirements)'
|
|
88
89
|
}),
|
|
89
90
|
(0, _classvalidator.IsString)(),
|
|
91
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
92
|
+
(0, _passwordvalidator.IsStrongPassword)(),
|
|
93
|
+
(0, _classvalidator.MaxLength)(128),
|
|
90
94
|
_ts_metadata("design:type", String)
|
|
91
95
|
], CreateUserDto.prototype, "password", void 0);
|
|
92
96
|
_ts_decorate([
|
|
@@ -139,6 +143,7 @@ let UpdateUserDto = class UpdateUserDto {
|
|
|
139
143
|
_define_property(this, "phone", void 0);
|
|
140
144
|
_define_property(this, "email", void 0);
|
|
141
145
|
_define_property(this, "password", void 0);
|
|
146
|
+
_define_property(this, "oldPassword", void 0);
|
|
142
147
|
_define_property(this, "profilePictureId", void 0);
|
|
143
148
|
_define_property(this, "isActive", void 0);
|
|
144
149
|
_define_property(this, "emailVerified", void 0);
|
|
@@ -150,7 +155,7 @@ _ts_decorate([
|
|
|
150
155
|
(0, _swagger.ApiProperty)({
|
|
151
156
|
description: 'User ID'
|
|
152
157
|
}),
|
|
153
|
-
(0, _classvalidator.
|
|
158
|
+
(0, _classvalidator.IsUUID)(),
|
|
154
159
|
_ts_metadata("design:type", String)
|
|
155
160
|
], UpdateUserDto.prototype, "id", void 0);
|
|
156
161
|
_ts_decorate([
|
|
@@ -182,12 +187,22 @@ _ts_decorate([
|
|
|
182
187
|
], UpdateUserDto.prototype, "email", void 0);
|
|
183
188
|
_ts_decorate([
|
|
184
189
|
(0, _swagger.ApiPropertyOptional)({
|
|
185
|
-
description: 'New password'
|
|
190
|
+
description: 'New password (must meet complexity requirements)'
|
|
186
191
|
}),
|
|
187
192
|
(0, _classvalidator.IsOptional)(),
|
|
188
193
|
(0, _classvalidator.IsString)(),
|
|
194
|
+
(0, _passwordvalidator.IsStrongPassword)(),
|
|
195
|
+
(0, _classvalidator.MaxLength)(128),
|
|
189
196
|
_ts_metadata("design:type", String)
|
|
190
197
|
], UpdateUserDto.prototype, "password", void 0);
|
|
198
|
+
_ts_decorate([
|
|
199
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
200
|
+
description: 'Current password (required when changing password on own profile)'
|
|
201
|
+
}),
|
|
202
|
+
(0, _classvalidator.IsOptional)(),
|
|
203
|
+
(0, _classvalidator.IsString)(),
|
|
204
|
+
_ts_metadata("design:type", String)
|
|
205
|
+
], UpdateUserDto.prototype, "oldPassword", void 0);
|
|
191
206
|
_ts_decorate([
|
|
192
207
|
(0, _swagger.ApiPropertyOptional)({
|
|
193
208
|
description: 'Profile picture file ID'
|
package/cjs/entities/index.js
CHANGED
|
@@ -30,8 +30,10 @@ _export(exports, {
|
|
|
30
30
|
});
|
|
31
31
|
const _companybranchentity = _export_star(require("./company-branch.entity"), exports);
|
|
32
32
|
const _companyentity = _export_star(require("./company.entity"), exports);
|
|
33
|
+
const _pendingregistrationentity = _export_star(require("./pending-registration.entity"), exports);
|
|
33
34
|
const _usercompanypermissionentity = require("./user-company-permission.entity");
|
|
34
35
|
const _userentity = _export_star(require("./user.entity"), exports);
|
|
36
|
+
const _usertokenentity = _export_star(require("./user-token.entity"), exports);
|
|
35
37
|
function _export_star(from, to) {
|
|
36
38
|
Object.keys(from).forEach(function(k) {
|
|
37
39
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -46,7 +48,9 @@ function _export_star(from, to) {
|
|
|
46
48
|
return from;
|
|
47
49
|
}
|
|
48
50
|
const CoreEntities = [
|
|
49
|
-
_userentity.User
|
|
51
|
+
_userentity.User,
|
|
52
|
+
_usertokenentity.UserToken,
|
|
53
|
+
_pendingregistrationentity.PendingRegistration
|
|
50
54
|
];
|
|
51
55
|
const CompanyEntities = [
|
|
52
56
|
_companyentity.Company,
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "PendingRegistration", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return PendingRegistration;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _typeorm = require("typeorm");
|
|
12
|
+
function _define_property(obj, key, value) {
|
|
13
|
+
if (key in obj) {
|
|
14
|
+
Object.defineProperty(obj, key, {
|
|
15
|
+
value: value,
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true
|
|
19
|
+
});
|
|
20
|
+
} else {
|
|
21
|
+
obj[key] = value;
|
|
22
|
+
}
|
|
23
|
+
return obj;
|
|
24
|
+
}
|
|
25
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
26
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
27
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
28
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
29
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
30
|
+
}
|
|
31
|
+
function _ts_metadata(k, v) {
|
|
32
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
|
+
}
|
|
34
|
+
let PendingRegistration = class PendingRegistration {
|
|
35
|
+
constructor(){
|
|
36
|
+
_define_property(this, "id", void 0);
|
|
37
|
+
_define_property(this, "email", void 0);
|
|
38
|
+
_define_property(this, "name", void 0);
|
|
39
|
+
_define_property(this, "phone", void 0);
|
|
40
|
+
_define_property(this, "passwordHash", void 0);
|
|
41
|
+
_define_property(this, "token", void 0);
|
|
42
|
+
_define_property(this, "expiresAt", void 0);
|
|
43
|
+
_define_property(this, "companyData", void 0);
|
|
44
|
+
_define_property(this, "createdAt", void 0);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
_ts_decorate([
|
|
48
|
+
(0, _typeorm.PrimaryGeneratedColumn)('uuid'),
|
|
49
|
+
_ts_metadata("design:type", String)
|
|
50
|
+
], PendingRegistration.prototype, "id", void 0);
|
|
51
|
+
_ts_decorate([
|
|
52
|
+
(0, _typeorm.Column)({
|
|
53
|
+
type: 'varchar',
|
|
54
|
+
length: 255
|
|
55
|
+
}),
|
|
56
|
+
_ts_metadata("design:type", String)
|
|
57
|
+
], PendingRegistration.prototype, "email", void 0);
|
|
58
|
+
_ts_decorate([
|
|
59
|
+
(0, _typeorm.Column)({
|
|
60
|
+
type: 'varchar',
|
|
61
|
+
length: 255,
|
|
62
|
+
nullable: true
|
|
63
|
+
}),
|
|
64
|
+
_ts_metadata("design:type", Object)
|
|
65
|
+
], PendingRegistration.prototype, "name", void 0);
|
|
66
|
+
_ts_decorate([
|
|
67
|
+
(0, _typeorm.Column)({
|
|
68
|
+
type: 'varchar',
|
|
69
|
+
length: 255,
|
|
70
|
+
nullable: true
|
|
71
|
+
}),
|
|
72
|
+
_ts_metadata("design:type", Object)
|
|
73
|
+
], PendingRegistration.prototype, "phone", void 0);
|
|
74
|
+
_ts_decorate([
|
|
75
|
+
(0, _typeorm.Column)({
|
|
76
|
+
type: 'text',
|
|
77
|
+
name: 'passwordHash'
|
|
78
|
+
}),
|
|
79
|
+
_ts_metadata("design:type", String)
|
|
80
|
+
], PendingRegistration.prototype, "passwordHash", void 0);
|
|
81
|
+
_ts_decorate([
|
|
82
|
+
(0, _typeorm.Column)({
|
|
83
|
+
type: 'varchar',
|
|
84
|
+
length: 64
|
|
85
|
+
}),
|
|
86
|
+
_ts_metadata("design:type", String)
|
|
87
|
+
], PendingRegistration.prototype, "token", void 0);
|
|
88
|
+
_ts_decorate([
|
|
89
|
+
(0, _typeorm.Column)({
|
|
90
|
+
type: 'timestamp',
|
|
91
|
+
name: 'expires_at'
|
|
92
|
+
}),
|
|
93
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
94
|
+
], PendingRegistration.prototype, "expiresAt", void 0);
|
|
95
|
+
_ts_decorate([
|
|
96
|
+
(0, _typeorm.Column)({
|
|
97
|
+
type: 'json',
|
|
98
|
+
nullable: true,
|
|
99
|
+
name: 'company_data'
|
|
100
|
+
}),
|
|
101
|
+
_ts_metadata("design:type", Object)
|
|
102
|
+
], PendingRegistration.prototype, "companyData", void 0);
|
|
103
|
+
_ts_decorate([
|
|
104
|
+
(0, _typeorm.CreateDateColumn)({
|
|
105
|
+
type: 'timestamp',
|
|
106
|
+
name: 'created_at'
|
|
107
|
+
}),
|
|
108
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
109
|
+
], PendingRegistration.prototype, "createdAt", void 0);
|
|
110
|
+
PendingRegistration = _ts_decorate([
|
|
111
|
+
(0, _typeorm.Entity)('pending_registrations'),
|
|
112
|
+
(0, _typeorm.Index)('IDX_pending_reg_email', [
|
|
113
|
+
'email'
|
|
114
|
+
], {
|
|
115
|
+
unique: true
|
|
116
|
+
}),
|
|
117
|
+
(0, _typeorm.Index)('IDX_pending_reg_token', [
|
|
118
|
+
'token'
|
|
119
|
+
], {
|
|
120
|
+
unique: true
|
|
121
|
+
}),
|
|
122
|
+
(0, _typeorm.Index)('IDX_pending_reg_expires', [
|
|
123
|
+
'expiresAt'
|
|
124
|
+
])
|
|
125
|
+
], PendingRegistration);
|
|
@@ -44,12 +44,6 @@ function _ts_metadata(k, v) {
|
|
|
44
44
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
45
45
|
}
|
|
46
46
|
let UserCompanyPermission = class UserCompanyPermission {
|
|
47
|
-
/* ---------- Helpers ---------- */ isCompanyPermission() {
|
|
48
|
-
return this.permissionType === _enums.PermissionType.COMPANY;
|
|
49
|
-
}
|
|
50
|
-
isBranchPermission() {
|
|
51
|
-
return this.permissionType === _enums.PermissionType.BRANCH;
|
|
52
|
-
}
|
|
53
47
|
constructor(){
|
|
54
48
|
_define_property(this, "id", void 0);
|
|
55
49
|
/* ---------- Ownership ---------- */ _define_property(this, "userId", void 0);
|
|
@@ -86,11 +80,11 @@ _ts_decorate([
|
|
|
86
80
|
], UserCompanyPermission.prototype, "user", void 0);
|
|
87
81
|
_ts_decorate([
|
|
88
82
|
(0, _typeorm.Column)({
|
|
89
|
-
type: '
|
|
90
|
-
|
|
83
|
+
type: 'varchar',
|
|
84
|
+
length: 50,
|
|
91
85
|
name: 'permission_type'
|
|
92
86
|
}),
|
|
93
|
-
_ts_metadata("design:type",
|
|
87
|
+
_ts_metadata("design:type", String)
|
|
94
88
|
], UserCompanyPermission.prototype, "permissionType", void 0);
|
|
95
89
|
_ts_decorate([
|
|
96
90
|
(0, _typeorm.Column)({
|