@flusys/nestjs-auth 1.1.0-beta → 1.1.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 +633 -468
- package/cjs/config/auth.constants.js +8 -0
- package/cjs/controllers/authentication.controller.js +175 -167
- 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/email-verification.controller.js +220 -0
- package/cjs/controllers/index.js +1 -0
- package/cjs/controllers/user-permission.controller.js +82 -154
- package/cjs/controllers/user.controller.js +68 -15
- package/cjs/docs/auth-swagger.config.js +14 -7
- package/cjs/dtos/authentication.dto.js +16 -43
- 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 +16 -17
- package/cjs/entities/user-company-permission.entity.js +3 -9
- 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 +1 -1
- package/cjs/modules/auth.module.js +79 -154
- package/cjs/services/auth-config.service.js +33 -35
- package/cjs/services/auth-datasource.provider.js +18 -42
- package/cjs/services/auth-email.service.js +89 -85
- package/cjs/services/authentication.service.js +248 -414
- package/cjs/services/branch.service.js +9 -4
- package/cjs/services/company-selection-session.service.js +1 -1
- package/cjs/services/user-permission.service.js +43 -73
- package/cjs/services/user.service.js +78 -64
- package/cjs/strategies/jwt.strategy.js +44 -44
- package/cjs/validators/password.validator.js +45 -0
- package/config/auth.constants.d.ts +2 -0
- package/controllers/authentication.controller.d.ts +4 -10
- package/controllers/company-selection.controller.d.ts +6 -2
- package/controllers/email-verification.controller.d.ts +20 -0
- package/controllers/index.d.ts +1 -0
- package/controllers/user-permission.controller.d.ts +5 -4
- package/controllers/user.controller.d.ts +6 -0
- package/dtos/authentication.dto.d.ts +0 -4
- 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 -3
- package/entities/index.d.ts +5 -10
- package/entities/user-company-permission.entity.d.ts +1 -3
- package/fesm/config/auth.constants.js +6 -13
- package/fesm/controllers/authentication.controller.js +178 -170
- 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/email-verification.controller.js +210 -0
- package/fesm/controllers/index.js +1 -0
- package/fesm/controllers/user-permission.controller.js +84 -156
- package/fesm/controllers/user.controller.js +71 -18
- package/fesm/docs/auth-swagger.config.js +14 -7
- package/fesm/dtos/authentication.dto.js +17 -44
- 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 +17 -9
- package/fesm/entities/user-company-permission.entity.js +3 -9
- 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 +1 -1
- package/fesm/modules/auth.module.js +82 -157
- package/fesm/services/auth-config.service.js +34 -36
- package/fesm/services/auth-datasource.provider.js +19 -43
- package/fesm/services/auth-email.service.js +90 -86
- package/fesm/services/authentication.service.js +248 -414
- package/fesm/services/branch.service.js +9 -4
- package/fesm/services/company-selection-session.service.js +1 -1
- package/fesm/services/user-permission.service.js +44 -74
- package/fesm/services/user.service.js +79 -65
- 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/authentication.interface.d.ts +0 -4
- package/interfaces/user-enricher.interface.d.ts +1 -4
- package/modules/auth.module.d.ts +9 -4
- package/package.json +4 -4
- package/services/auth-config.service.d.ts +7 -8
- package/services/auth-datasource.provider.d.ts +3 -4
- package/services/auth-email.service.d.ts +8 -4
- package/services/authentication.service.d.ts +16 -16
- package/services/company-selection-session.service.d.ts +1 -1
- package/services/user-permission.service.d.ts +6 -9
- package/services/user.service.d.ts +3 -0
- 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
|
@@ -44,35 +44,80 @@ function _ts_param(paramIndex, decorator) {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
let UserController = class UserController extends (0, _classes.createApiController)(_userdto.CreateUserDto, _userdto.UpdateUserDto, _userdto.UserResponseDto, {
|
|
47
|
-
security:
|
|
47
|
+
security: {
|
|
48
|
+
insert: {
|
|
49
|
+
level: 'permission',
|
|
50
|
+
permissions: [
|
|
51
|
+
_classes.USER_PERMISSIONS.CREATE
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
insertMany: {
|
|
55
|
+
level: 'permission',
|
|
56
|
+
permissions: [
|
|
57
|
+
_classes.USER_PERMISSIONS.CREATE
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
getById: {
|
|
61
|
+
level: 'permission',
|
|
62
|
+
permissions: [
|
|
63
|
+
_classes.USER_PERMISSIONS.READ
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
getAll: {
|
|
67
|
+
level: 'permission',
|
|
68
|
+
permissions: [
|
|
69
|
+
_classes.USER_PERMISSIONS.READ
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
update: {
|
|
73
|
+
level: 'permission',
|
|
74
|
+
permissions: [
|
|
75
|
+
_classes.USER_PERMISSIONS.UPDATE
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
updateMany: {
|
|
79
|
+
level: 'permission',
|
|
80
|
+
permissions: [
|
|
81
|
+
_classes.USER_PERMISSIONS.UPDATE
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
delete: {
|
|
85
|
+
level: 'permission',
|
|
86
|
+
permissions: [
|
|
87
|
+
_classes.USER_PERMISSIONS.DELETE
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
}
|
|
48
91
|
}) {
|
|
49
|
-
|
|
50
|
-
/** Get user profile with extras (roles, permissions, etc.) from enricher */ async getProfileWithExtras(id, user) {
|
|
92
|
+
async getProfileWithExtras(id, user) {
|
|
51
93
|
const data = await this.service.getProfileWithExtras(id, user);
|
|
52
94
|
return {
|
|
53
95
|
success: true,
|
|
54
96
|
data
|
|
55
97
|
};
|
|
56
98
|
}
|
|
57
|
-
|
|
99
|
+
async verifyEmail(id) {
|
|
58
100
|
await this.service.verifyEmail(id);
|
|
59
101
|
return {
|
|
102
|
+
success: true,
|
|
60
103
|
message: 'Email verified successfully'
|
|
61
104
|
};
|
|
62
105
|
}
|
|
63
|
-
|
|
106
|
+
async verifyPhone(id) {
|
|
64
107
|
await this.service.verifyPhone(id);
|
|
65
108
|
return {
|
|
109
|
+
success: true,
|
|
66
110
|
message: 'Phone verified successfully'
|
|
67
111
|
};
|
|
68
112
|
}
|
|
69
|
-
|
|
113
|
+
async updateStatus(id, isActive, user) {
|
|
70
114
|
await this.service.updateStatus(id, isActive, user);
|
|
71
115
|
return {
|
|
116
|
+
success: true,
|
|
72
117
|
message: 'Status updated successfully'
|
|
73
118
|
};
|
|
74
119
|
}
|
|
75
|
-
|
|
120
|
+
async profile(dto, user) {
|
|
76
121
|
const data = await this.service.profile(dto, user);
|
|
77
122
|
return {
|
|
78
123
|
success: true,
|
|
@@ -80,34 +125,34 @@ let UserController = class UserController extends (0, _classes.createApiControll
|
|
|
80
125
|
data
|
|
81
126
|
};
|
|
82
127
|
}
|
|
83
|
-
|
|
84
|
-
// Multi-Step Profile Endpoints (via Enricher)
|
|
85
|
-
// ============================================
|
|
86
|
-
/** Get profile section definitions */ async getProfileSections() {
|
|
128
|
+
async getProfileSections() {
|
|
87
129
|
const sections = await this.service.getProfileSections();
|
|
88
130
|
return {
|
|
89
131
|
success: true,
|
|
132
|
+
message: 'Profile sections retrieved successfully',
|
|
90
133
|
data: sections
|
|
91
134
|
};
|
|
92
135
|
}
|
|
93
|
-
|
|
136
|
+
async getProfileSectionData(id, sectionId, user) {
|
|
94
137
|
const data = await this.service.getProfileSectionData(id, sectionId, user);
|
|
95
138
|
return {
|
|
96
139
|
success: true,
|
|
140
|
+
message: 'Profile section data retrieved successfully',
|
|
97
141
|
data
|
|
98
142
|
};
|
|
99
143
|
}
|
|
100
|
-
|
|
144
|
+
async updateProfileSection(id, sectionId, data, user) {
|
|
101
145
|
await this.service.updateProfileSection(id, sectionId, data, user);
|
|
102
146
|
return {
|
|
103
147
|
success: true,
|
|
104
148
|
message: 'Section updated successfully'
|
|
105
149
|
};
|
|
106
150
|
}
|
|
107
|
-
|
|
151
|
+
async getProfileCompletion(id, user) {
|
|
108
152
|
const percentage = await this.service.getProfileCompletion(id, user);
|
|
109
153
|
return {
|
|
110
154
|
success: true,
|
|
155
|
+
message: 'Profile completion retrieved successfully',
|
|
111
156
|
data: {
|
|
112
157
|
completionPercentage: percentage
|
|
113
158
|
}
|
|
@@ -121,6 +166,7 @@ _ts_decorate([
|
|
|
121
166
|
(0, _common.Post)(':id/profile-extras'),
|
|
122
167
|
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
123
168
|
(0, _swagger.ApiBearerAuth)(),
|
|
169
|
+
(0, _decorators.RequirePermission)(_classes.USER_PERMISSIONS.READ),
|
|
124
170
|
(0, _swagger.ApiOperation)({
|
|
125
171
|
summary: 'Get user profile with extras',
|
|
126
172
|
description: 'Returns user profile along with extra data (roles, permissions, etc.) if UserEnricher is provided.'
|
|
@@ -142,6 +188,7 @@ _ts_decorate([
|
|
|
142
188
|
(0, _common.Post)(':id/verify-email'),
|
|
143
189
|
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
144
190
|
(0, _swagger.ApiBearerAuth)(),
|
|
191
|
+
(0, _decorators.RequirePermission)(_classes.USER_PERMISSIONS.UPDATE),
|
|
145
192
|
(0, _swagger.ApiOperation)({
|
|
146
193
|
summary: 'Verify user email'
|
|
147
194
|
}),
|
|
@@ -160,6 +207,7 @@ _ts_decorate([
|
|
|
160
207
|
(0, _common.Post)(':id/verify-phone'),
|
|
161
208
|
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
162
209
|
(0, _swagger.ApiBearerAuth)(),
|
|
210
|
+
(0, _decorators.RequirePermission)(_classes.USER_PERMISSIONS.UPDATE),
|
|
163
211
|
(0, _swagger.ApiOperation)({
|
|
164
212
|
summary: 'Verify user phone'
|
|
165
213
|
}),
|
|
@@ -175,9 +223,10 @@ _ts_decorate([
|
|
|
175
223
|
_ts_metadata("design:returntype", Promise)
|
|
176
224
|
], UserController.prototype, "verifyPhone", null);
|
|
177
225
|
_ts_decorate([
|
|
178
|
-
(0, _common.
|
|
226
|
+
(0, _common.Post)(':id/status'),
|
|
179
227
|
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
180
228
|
(0, _swagger.ApiBearerAuth)(),
|
|
229
|
+
(0, _decorators.RequirePermission)(_classes.USER_PERMISSIONS.UPDATE),
|
|
181
230
|
(0, _swagger.ApiOperation)({
|
|
182
231
|
summary: 'Update user active status',
|
|
183
232
|
description: 'Updates user active status. When company feature is enabled, updates the status for the current company context.'
|
|
@@ -227,6 +276,7 @@ _ts_decorate([
|
|
|
227
276
|
(0, _common.Post)('profile-sections'),
|
|
228
277
|
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
229
278
|
(0, _swagger.ApiBearerAuth)(),
|
|
279
|
+
(0, _decorators.RequirePermission)(_classes.USER_PERMISSIONS.READ),
|
|
230
280
|
(0, _swagger.ApiOperation)({
|
|
231
281
|
summary: 'Get profile section definitions',
|
|
232
282
|
description: 'Returns available profile sections for multi-step profile (if enricher configured).'
|
|
@@ -239,6 +289,7 @@ _ts_decorate([
|
|
|
239
289
|
(0, _common.Post)(':id/profile-section/:sectionId'),
|
|
240
290
|
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
241
291
|
(0, _swagger.ApiBearerAuth)(),
|
|
292
|
+
(0, _decorators.RequirePermission)(_classes.USER_PERMISSIONS.READ),
|
|
242
293
|
(0, _swagger.ApiOperation)({
|
|
243
294
|
summary: 'Get profile section data',
|
|
244
295
|
description: 'Returns data for a specific profile section.'
|
|
@@ -266,6 +317,7 @@ _ts_decorate([
|
|
|
266
317
|
(0, _common.Post)(':id/profile-section/:sectionId/update'),
|
|
267
318
|
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
268
319
|
(0, _swagger.ApiBearerAuth)(),
|
|
320
|
+
(0, _decorators.RequirePermission)(_classes.USER_PERMISSIONS.UPDATE),
|
|
269
321
|
(0, _swagger.ApiOperation)({
|
|
270
322
|
summary: 'Update profile section',
|
|
271
323
|
description: 'Updates a specific profile section data.'
|
|
@@ -295,6 +347,7 @@ _ts_decorate([
|
|
|
295
347
|
(0, _common.Post)(':id/profile-completion'),
|
|
296
348
|
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
297
349
|
(0, _swagger.ApiBearerAuth)(),
|
|
350
|
+
(0, _decorators.RequirePermission)(_classes.USER_PERMISSIONS.READ),
|
|
298
351
|
(0, _swagger.ApiOperation)({
|
|
299
352
|
summary: 'Get profile completion percentage',
|
|
300
353
|
description: 'Returns overall profile completion percentage.'
|
|
@@ -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
|
}
|
|
@@ -72,6 +72,7 @@ _export(exports, {
|
|
|
72
72
|
});
|
|
73
73
|
const _swagger = require("@nestjs/swagger");
|
|
74
74
|
const _classvalidator = require("class-validator");
|
|
75
|
+
const _passwordvalidator = require("../validators/password.validator");
|
|
75
76
|
function _define_property(obj, key, value) {
|
|
76
77
|
if (key in obj) {
|
|
77
78
|
Object.defineProperty(obj, key, {
|
|
@@ -111,12 +112,12 @@ _ts_decorate([
|
|
|
111
112
|
], LoginDto.prototype, "email", void 0);
|
|
112
113
|
_ts_decorate([
|
|
113
114
|
(0, _swagger.ApiProperty)({
|
|
114
|
-
example: '
|
|
115
|
-
description: 'User password
|
|
115
|
+
example: 'SecureP@ss1',
|
|
116
|
+
description: 'User password'
|
|
116
117
|
}),
|
|
117
118
|
(0, _classvalidator.IsString)(),
|
|
118
119
|
(0, _classvalidator.IsNotEmpty)(),
|
|
119
|
-
(0, _classvalidator.
|
|
120
|
+
(0, _classvalidator.MaxLength)(128),
|
|
120
121
|
_ts_metadata("design:type", String)
|
|
121
122
|
], LoginDto.prototype, "password", void 0);
|
|
122
123
|
let RegistrationDto = class RegistrationDto {
|
|
@@ -155,13 +156,13 @@ _ts_decorate([
|
|
|
155
156
|
], RegistrationDto.prototype, "email", void 0);
|
|
156
157
|
_ts_decorate([
|
|
157
158
|
(0, _swagger.ApiProperty)({
|
|
158
|
-
example: '
|
|
159
|
-
description: 'Password (min
|
|
159
|
+
example: 'StrongP@ss123',
|
|
160
|
+
description: 'Password (min 8 chars, requires uppercase, lowercase, number, special char)'
|
|
160
161
|
}),
|
|
161
162
|
(0, _classvalidator.IsNotEmpty)(),
|
|
162
163
|
(0, _classvalidator.IsString)(),
|
|
163
|
-
(0,
|
|
164
|
-
(0, _classvalidator.MaxLength)(
|
|
164
|
+
(0, _passwordvalidator.IsStrongPassword)(),
|
|
165
|
+
(0, _classvalidator.MaxLength)(128),
|
|
165
166
|
_ts_metadata("design:type", String)
|
|
166
167
|
], RegistrationDto.prototype, "password", void 0);
|
|
167
168
|
_ts_decorate([
|
|
@@ -222,6 +223,7 @@ _ts_decorate([
|
|
|
222
223
|
}),
|
|
223
224
|
(0, _classvalidator.IsOptional)(),
|
|
224
225
|
(0, _classvalidator.IsString)(),
|
|
226
|
+
(0, _classvalidator.MaxLength)(500),
|
|
225
227
|
_ts_metadata("design:type", String)
|
|
226
228
|
], RegistrationDto.prototype, "newCompanyAddress", void 0);
|
|
227
229
|
let RefreshTokenDto = class RefreshTokenDto {
|
|
@@ -251,16 +253,17 @@ _ts_decorate([
|
|
|
251
253
|
}),
|
|
252
254
|
(0, _classvalidator.IsString)(),
|
|
253
255
|
(0, _classvalidator.IsNotEmpty)(),
|
|
256
|
+
(0, _classvalidator.MaxLength)(128),
|
|
254
257
|
_ts_metadata("design:type", String)
|
|
255
258
|
], ChangePasswordDto.prototype, "currentPassword", void 0);
|
|
256
259
|
_ts_decorate([
|
|
257
260
|
(0, _swagger.ApiProperty)({
|
|
258
|
-
example: '
|
|
259
|
-
description: 'New password (min
|
|
261
|
+
example: 'NewP@ssword456',
|
|
262
|
+
description: 'New password (min 8 chars, requires uppercase, lowercase, number, special char)'
|
|
260
263
|
}),
|
|
261
264
|
(0, _classvalidator.IsString)(),
|
|
262
265
|
(0, _classvalidator.IsNotEmpty)(),
|
|
263
|
-
(0,
|
|
266
|
+
(0, _passwordvalidator.IsStrongPassword)(),
|
|
264
267
|
_ts_metadata("design:type", String)
|
|
265
268
|
], ChangePasswordDto.prototype, "newPassword", void 0);
|
|
266
269
|
let SelectDto = class SelectDto {
|
|
@@ -428,7 +431,6 @@ let BranchSelectionInfoDto = class BranchSelectionInfoDto {
|
|
|
428
431
|
_define_property(this, "id", void 0);
|
|
429
432
|
_define_property(this, "name", void 0);
|
|
430
433
|
_define_property(this, "slug", void 0);
|
|
431
|
-
_define_property(this, "isActive", void 0);
|
|
432
434
|
_define_property(this, "logoId", void 0);
|
|
433
435
|
}
|
|
434
436
|
};
|
|
@@ -450,12 +452,6 @@ _ts_decorate([
|
|
|
450
452
|
}),
|
|
451
453
|
_ts_metadata("design:type", String)
|
|
452
454
|
], BranchSelectionInfoDto.prototype, "slug", void 0);
|
|
453
|
-
_ts_decorate([
|
|
454
|
-
(0, _swagger.ApiProperty)({
|
|
455
|
-
example: true
|
|
456
|
-
}),
|
|
457
|
-
_ts_metadata("design:type", Boolean)
|
|
458
|
-
], BranchSelectionInfoDto.prototype, "isActive", void 0);
|
|
459
455
|
_ts_decorate([
|
|
460
456
|
(0, _swagger.ApiPropertyOptional)({
|
|
461
457
|
example: '550e8400-e29b-41d4-a716-446655440077',
|
|
@@ -469,7 +465,6 @@ let CompanyWithBranchesDto = class CompanyWithBranchesDto {
|
|
|
469
465
|
_define_property(this, "id", void 0);
|
|
470
466
|
_define_property(this, "name", void 0);
|
|
471
467
|
_define_property(this, "slug", void 0);
|
|
472
|
-
_define_property(this, "isActive", void 0);
|
|
473
468
|
_define_property(this, "logoId", void 0);
|
|
474
469
|
_define_property(this, "branches", void 0);
|
|
475
470
|
}
|
|
@@ -492,12 +487,6 @@ _ts_decorate([
|
|
|
492
487
|
}),
|
|
493
488
|
_ts_metadata("design:type", String)
|
|
494
489
|
], CompanyWithBranchesDto.prototype, "slug", void 0);
|
|
495
|
-
_ts_decorate([
|
|
496
|
-
(0, _swagger.ApiProperty)({
|
|
497
|
-
example: true
|
|
498
|
-
}),
|
|
499
|
-
_ts_metadata("design:type", Boolean)
|
|
500
|
-
], CompanyWithBranchesDto.prototype, "isActive", void 0);
|
|
501
490
|
_ts_decorate([
|
|
502
491
|
(0, _swagger.ApiPropertyOptional)({
|
|
503
492
|
example: '550e8400-e29b-41d4-a716-446655440088',
|
|
@@ -522,7 +511,6 @@ let LoginResponseDto = class LoginResponseDto {
|
|
|
522
511
|
_define_property(this, "user", void 0);
|
|
523
512
|
_define_property(this, "company", void 0);
|
|
524
513
|
_define_property(this, "branch", void 0);
|
|
525
|
-
_define_property(this, "companyFeatureEnabled", void 0);
|
|
526
514
|
}
|
|
527
515
|
};
|
|
528
516
|
_ts_decorate([
|
|
@@ -558,13 +546,6 @@ _ts_decorate([
|
|
|
558
546
|
}),
|
|
559
547
|
_ts_metadata("design:type", typeof BranchInfoDto === "undefined" ? Object : BranchInfoDto)
|
|
560
548
|
], LoginResponseDto.prototype, "branch", void 0);
|
|
561
|
-
_ts_decorate([
|
|
562
|
-
(0, _swagger.ApiPropertyOptional)({
|
|
563
|
-
example: true,
|
|
564
|
-
description: 'Whether company feature is enabled'
|
|
565
|
-
}),
|
|
566
|
-
_ts_metadata("design:type", Boolean)
|
|
567
|
-
], LoginResponseDto.prototype, "companyFeatureEnabled", void 0);
|
|
568
549
|
let RegistrationResponseDto = class RegistrationResponseDto {
|
|
569
550
|
constructor(){
|
|
570
551
|
_define_property(this, "accessToken", void 0);
|
|
@@ -572,7 +553,6 @@ let RegistrationResponseDto = class RegistrationResponseDto {
|
|
|
572
553
|
_define_property(this, "user", void 0);
|
|
573
554
|
_define_property(this, "company", void 0);
|
|
574
555
|
_define_property(this, "branch", void 0);
|
|
575
|
-
_define_property(this, "companyFeatureEnabled", void 0);
|
|
576
556
|
_define_property(this, "requiresEmailVerification", void 0);
|
|
577
557
|
}
|
|
578
558
|
};
|
|
@@ -609,13 +589,6 @@ _ts_decorate([
|
|
|
609
589
|
}),
|
|
610
590
|
_ts_metadata("design:type", typeof BranchInfoDto === "undefined" ? Object : BranchInfoDto)
|
|
611
591
|
], RegistrationResponseDto.prototype, "branch", void 0);
|
|
612
|
-
_ts_decorate([
|
|
613
|
-
(0, _swagger.ApiPropertyOptional)({
|
|
614
|
-
example: true,
|
|
615
|
-
description: 'Whether company feature is enabled'
|
|
616
|
-
}),
|
|
617
|
-
_ts_metadata("design:type", Boolean)
|
|
618
|
-
], RegistrationResponseDto.prototype, "companyFeatureEnabled", void 0);
|
|
619
592
|
_ts_decorate([
|
|
620
593
|
(0, _swagger.ApiPropertyOptional)({
|
|
621
594
|
example: true,
|
|
@@ -753,12 +726,12 @@ _ts_decorate([
|
|
|
753
726
|
], ResetPasswordDto.prototype, "token", void 0);
|
|
754
727
|
_ts_decorate([
|
|
755
728
|
(0, _swagger.ApiProperty)({
|
|
756
|
-
example: '
|
|
757
|
-
description: 'New password (min
|
|
729
|
+
example: 'NewSecureP@ss123',
|
|
730
|
+
description: 'New password (min 8 chars, requires uppercase, lowercase, number, special char)'
|
|
758
731
|
}),
|
|
759
732
|
(0, _classvalidator.IsString)(),
|
|
760
733
|
(0, _classvalidator.IsNotEmpty)(),
|
|
761
|
-
(0,
|
|
734
|
+
(0, _passwordvalidator.IsStrongPassword)(),
|
|
762
735
|
_ts_metadata("design:type", String)
|
|
763
736
|
], ResetPasswordDto.prototype, "newPassword", void 0);
|
|
764
737
|
let VerifyEmailDto = class VerifyEmailDto {
|
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
|
@@ -9,15 +9,6 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
get AllEntities () {
|
|
13
|
-
return AllEntities;
|
|
14
|
-
},
|
|
15
|
-
get CompanyEntities () {
|
|
16
|
-
return CompanyEntities;
|
|
17
|
-
},
|
|
18
|
-
get CoreEntities () {
|
|
19
|
-
return CoreEntities;
|
|
20
|
-
},
|
|
21
12
|
get PermissionType () {
|
|
22
13
|
return _usercompanypermissionentity.PermissionType;
|
|
23
14
|
},
|
|
@@ -47,9 +38,11 @@ function _export_star(from, to) {
|
|
|
47
38
|
});
|
|
48
39
|
return from;
|
|
49
40
|
}
|
|
50
|
-
const
|
|
41
|
+
const BaseEntities = [
|
|
51
42
|
_userentity.User,
|
|
52
|
-
_usertokenentity.UserToken
|
|
43
|
+
_usertokenentity.UserToken
|
|
44
|
+
];
|
|
45
|
+
const EmailEntities = [
|
|
53
46
|
_pendingregistrationentity.PendingRegistration
|
|
54
47
|
];
|
|
55
48
|
const CompanyEntities = [
|
|
@@ -57,10 +50,16 @@ const CompanyEntities = [
|
|
|
57
50
|
_companybranchentity.CompanyBranch,
|
|
58
51
|
_usercompanypermissionentity.UserCompanyPermission
|
|
59
52
|
];
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
53
|
+
function getEntitiesByConfig(config) {
|
|
54
|
+
const { enableCompanyFeature = false, enableEmailVerification = true } = config;
|
|
55
|
+
const entities = [
|
|
56
|
+
...BaseEntities
|
|
57
|
+
];
|
|
58
|
+
if (enableEmailVerification) {
|
|
59
|
+
entities.push(...EmailEntities);
|
|
60
|
+
}
|
|
61
|
+
if (enableCompanyFeature) {
|
|
62
|
+
entities.push(...CompanyEntities);
|
|
63
|
+
}
|
|
64
|
+
return entities;
|
|
66
65
|
}
|
|
@@ -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)({
|