@flusys/nestjs-auth 1.0.0-beta → 1.0.0-rc
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 +274 -291
- package/cjs/config/auth.constants.js +12 -0
- package/cjs/controllers/authentication.controller.js +219 -10
- 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 +40 -25
- package/cjs/controllers/user.controller.js +211 -7
- package/cjs/dtos/authentication.dto.js +119 -13
- 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 +0 -6
- package/cjs/entities/user-token.entity.js +129 -0
- package/cjs/guards/auth-throttler.guard.js +53 -0
- package/cjs/interceptors/clear-token.interceptor.js +3 -6
- package/cjs/interceptors/set-token.interceptor.js +38 -31
- 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 +8 -20
- package/cjs/services/auth-config.service.js +23 -2
- package/cjs/services/auth-datasource.provider.js +5 -3
- package/cjs/services/auth-email.service.js +471 -0
- package/cjs/services/authentication.service.js +169 -77
- package/cjs/services/branch.service.js +6 -5
- package/cjs/services/company-selection-session.service.js +1 -1
- package/cjs/services/index.js +1 -0
- package/cjs/services/user-permission.service.js +0 -2
- package/cjs/services/user.service.js +213 -34
- package/cjs/validators/password.validator.js +45 -0
- package/config/auth.constants.d.ts +3 -0
- package/controllers/authentication.controller.d.ts +13 -9
- package/controllers/company-selection.controller.d.ts +6 -2
- package/controllers/user.controller.d.ts +33 -0
- package/dtos/authentication.dto.d.ts +21 -3
- package/dtos/company-branch.dto.d.ts +0 -1
- package/dtos/company.dto.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 +0 -2
- package/entities/user-token.entity.d.ts +15 -0
- package/fesm/config/auth.constants.js +6 -2
- package/fesm/controllers/authentication.controller.js +221 -12
- 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 +41 -26
- package/fesm/controllers/user.controller.js +214 -10
- package/fesm/dtos/authentication.dto.js +106 -14
- 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 +0 -6
- package/fesm/entities/user-token.entity.js +113 -0
- package/fesm/guards/auth-throttler.guard.js +43 -0
- package/fesm/interceptors/clear-token.interceptor.js +2 -5
- package/fesm/interceptors/set-token.interceptor.js +37 -30
- 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 +10 -22
- package/fesm/services/auth-config.service.js +24 -3
- package/fesm/services/auth-datasource.provider.js +6 -4
- package/fesm/services/auth-email.service.js +420 -0
- package/fesm/services/authentication.service.js +169 -77
- package/fesm/services/branch.service.js +6 -5
- package/fesm/services/company-selection-session.service.js +1 -1
- package/fesm/services/index.js +1 -0
- package/fesm/services/user-permission.service.js +1 -3
- package/fesm/services/user.service.js +215 -36
- package/fesm/validators/password.validator.js +48 -0
- package/guards/auth-throttler.guard.d.ts +7 -0
- package/interceptors/set-token.interceptor.d.ts +1 -0
- 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 +14 -0
- 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 +0 -1
- package/package.json +4 -4
- package/services/auth-config.service.d.ts +5 -1
- package/services/auth-email.service.d.ts +51 -0
- package/services/authentication.service.d.ts +16 -11
- package/services/company-selection-session.service.d.ts +1 -1
- package/services/index.d.ts +1 -0
- package/services/user-permission.service.d.ts +0 -1
- package/services/user.service.d.ts +19 -3
- package/validators/password.validator.d.ts +10 -0
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "UserPermissionController", {
|
|
|
10
10
|
});
|
|
11
11
|
const _common = require("@nestjs/common");
|
|
12
12
|
const _swagger = require("@nestjs/swagger");
|
|
13
|
-
const
|
|
13
|
+
const _nestjsshared = require("@flusys/nestjs-shared");
|
|
14
14
|
const _userpermissiondto = require("../dtos/user-permission.dto");
|
|
15
15
|
const _userpermissionservice = require("../services/user-permission.service");
|
|
16
16
|
function _define_property(obj, key, value) {
|
|
@@ -41,8 +41,7 @@ function _ts_param(paramIndex, decorator) {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
let UserPermissionController = class UserPermissionController {
|
|
44
|
-
|
|
45
|
-
/** Batch assign/revoke user-company permissions */ async assignUserCompany(dto) {
|
|
44
|
+
async assignUserCompany(dto) {
|
|
46
45
|
let addedCount = 0;
|
|
47
46
|
let removedCount = 0;
|
|
48
47
|
for (const item of dto.items){
|
|
@@ -62,9 +61,8 @@ let UserPermissionController = class UserPermissionController {
|
|
|
62
61
|
message: `Processed ${addedCount} additions and ${removedCount} removals`
|
|
63
62
|
};
|
|
64
63
|
}
|
|
65
|
-
|
|
64
|
+
async getUserCompanies(userId) {
|
|
66
65
|
const permissions = await this.userPermissionService.findUserCompanies(userId);
|
|
67
|
-
// Map to DTO format with populated company details
|
|
68
66
|
const data = permissions.map((permission)=>({
|
|
69
67
|
id: permission.id,
|
|
70
68
|
userId: permission.userId,
|
|
@@ -73,11 +71,12 @@ let UserPermissionController = class UserPermissionController {
|
|
|
73
71
|
companySlug: permission.company?.slug || ''
|
|
74
72
|
}));
|
|
75
73
|
return {
|
|
74
|
+
success: true,
|
|
75
|
+
message: 'User companies retrieved successfully',
|
|
76
76
|
data
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
|
-
|
|
80
|
-
/** Batch assign/revoke user-branch permissions */ async assignUserBranch(dto) {
|
|
79
|
+
async assignUserBranch(dto) {
|
|
81
80
|
let addedCount = 0;
|
|
82
81
|
let removedCount = 0;
|
|
83
82
|
for (const item of dto.items){
|
|
@@ -97,9 +96,8 @@ let UserPermissionController = class UserPermissionController {
|
|
|
97
96
|
message: `Processed ${addedCount} additions and ${removedCount} removals`
|
|
98
97
|
};
|
|
99
98
|
}
|
|
100
|
-
|
|
99
|
+
async getUserBranches(userId) {
|
|
101
100
|
const permissions = await this.userPermissionService.findUserBranches(userId);
|
|
102
|
-
// Map to DTO format with populated branch details
|
|
103
101
|
const data = permissions.map((permission)=>({
|
|
104
102
|
id: permission.id,
|
|
105
103
|
userId: permission.userId,
|
|
@@ -109,10 +107,11 @@ let UserPermissionController = class UserPermissionController {
|
|
|
109
107
|
companyId: permission.branch?.companyId || ''
|
|
110
108
|
}));
|
|
111
109
|
return {
|
|
110
|
+
success: true,
|
|
111
|
+
message: 'User branches retrieved successfully',
|
|
112
112
|
data
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
-
// NOTE: @Inject() required for bundled code - type metadata may be lost during esbuild
|
|
116
115
|
constructor(userPermissionService){
|
|
117
116
|
_define_property(this, "userPermissionService", void 0);
|
|
118
117
|
this.userPermissionService = userPermissionService;
|
|
@@ -120,6 +119,7 @@ let UserPermissionController = class UserPermissionController {
|
|
|
120
119
|
};
|
|
121
120
|
_ts_decorate([
|
|
122
121
|
(0, _common.Post)('user-company/assign'),
|
|
122
|
+
(0, _nestjsshared.RequirePermission)(_nestjsshared.USER_PERMISSIONS.UPDATE),
|
|
123
123
|
(0, _swagger.ApiOperation)({
|
|
124
124
|
summary: 'Batch assign/revoke user-company permissions',
|
|
125
125
|
description: `
|
|
@@ -174,22 +174,29 @@ Batch operation to assign or revoke user permissions to companies.
|
|
|
174
174
|
_ts_metadata("design:returntype", Promise)
|
|
175
175
|
], UserPermissionController.prototype, "assignUserCompany", null);
|
|
176
176
|
_ts_decorate([
|
|
177
|
-
(0, _common.
|
|
177
|
+
(0, _common.Post)('get-user-company'),
|
|
178
|
+
(0, _nestjsshared.RequirePermission)(_nestjsshared.USER_PERMISSIONS.READ),
|
|
178
179
|
(0, _swagger.ApiOperation)({
|
|
179
180
|
summary: 'Get user companies',
|
|
180
181
|
description: 'Returns all companies the user has access to.'
|
|
181
182
|
}),
|
|
182
|
-
(0, _swagger.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
183
|
+
(0, _swagger.ApiBody)({
|
|
184
|
+
schema: {
|
|
185
|
+
properties: {
|
|
186
|
+
userId: {
|
|
187
|
+
type: 'string'
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
required: [
|
|
191
|
+
'userId'
|
|
192
|
+
]
|
|
193
|
+
}
|
|
187
194
|
}),
|
|
188
195
|
(0, _swagger.ApiResponse)({
|
|
189
196
|
status: 200,
|
|
190
197
|
type: _userpermissiondto.UserCompaniesResponseDto
|
|
191
198
|
}),
|
|
192
|
-
_ts_param(0, (0, _common.
|
|
199
|
+
_ts_param(0, (0, _common.Body)('userId')),
|
|
193
200
|
_ts_metadata("design:type", Function),
|
|
194
201
|
_ts_metadata("design:paramtypes", [
|
|
195
202
|
String
|
|
@@ -198,6 +205,7 @@ _ts_decorate([
|
|
|
198
205
|
], UserPermissionController.prototype, "getUserCompanies", null);
|
|
199
206
|
_ts_decorate([
|
|
200
207
|
(0, _common.Post)('user-branch/assign'),
|
|
208
|
+
(0, _nestjsshared.RequirePermission)(_nestjsshared.USER_PERMISSIONS.UPDATE),
|
|
201
209
|
(0, _swagger.ApiOperation)({
|
|
202
210
|
summary: 'Batch assign/revoke user-branch permissions',
|
|
203
211
|
description: `
|
|
@@ -252,22 +260,29 @@ Batch operation to assign or revoke user permissions to branches.
|
|
|
252
260
|
_ts_metadata("design:returntype", Promise)
|
|
253
261
|
], UserPermissionController.prototype, "assignUserBranch", null);
|
|
254
262
|
_ts_decorate([
|
|
255
|
-
(0, _common.
|
|
263
|
+
(0, _common.Post)('get-user-branch'),
|
|
264
|
+
(0, _nestjsshared.RequirePermission)(_nestjsshared.USER_PERMISSIONS.READ),
|
|
256
265
|
(0, _swagger.ApiOperation)({
|
|
257
266
|
summary: 'Get user branches',
|
|
258
267
|
description: 'Returns all branches the user has access to.'
|
|
259
268
|
}),
|
|
260
|
-
(0, _swagger.
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
269
|
+
(0, _swagger.ApiBody)({
|
|
270
|
+
schema: {
|
|
271
|
+
properties: {
|
|
272
|
+
userId: {
|
|
273
|
+
type: 'string'
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
required: [
|
|
277
|
+
'userId'
|
|
278
|
+
]
|
|
279
|
+
}
|
|
265
280
|
}),
|
|
266
281
|
(0, _swagger.ApiResponse)({
|
|
267
282
|
status: 200,
|
|
268
283
|
type: _userpermissiondto.UserBranchesResponseDto
|
|
269
284
|
}),
|
|
270
|
-
_ts_param(0, (0, _common.
|
|
285
|
+
_ts_param(0, (0, _common.Body)('userId')),
|
|
271
286
|
_ts_metadata("design:type", Function),
|
|
272
287
|
_ts_metadata("design:paramtypes", [
|
|
273
288
|
String
|
|
@@ -278,7 +293,7 @@ UserPermissionController = _ts_decorate([
|
|
|
278
293
|
(0, _swagger.ApiTags)('User Permissions'),
|
|
279
294
|
(0, _swagger.ApiBearerAuth)(),
|
|
280
295
|
(0, _common.Controller)('administration/permissions'),
|
|
281
|
-
(0, _common.UseGuards)(
|
|
296
|
+
(0, _common.UseGuards)(_nestjsshared.JwtAuthGuard),
|
|
282
297
|
_ts_param(0, (0, _common.Inject)(_userpermissionservice.UserPermissionService)),
|
|
283
298
|
_ts_metadata("design:type", Function),
|
|
284
299
|
_ts_metadata("design:paramtypes", [
|
|
@@ -44,42 +44,151 @@ 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
|
-
|
|
92
|
+
async getProfileWithExtras(id, user) {
|
|
93
|
+
const data = await this.service.getProfileWithExtras(id, user);
|
|
94
|
+
return {
|
|
95
|
+
success: true,
|
|
96
|
+
data
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
async verifyEmail(id) {
|
|
51
100
|
await this.service.verifyEmail(id);
|
|
52
101
|
return {
|
|
102
|
+
success: true,
|
|
53
103
|
message: 'Email verified successfully'
|
|
54
104
|
};
|
|
55
105
|
}
|
|
56
|
-
|
|
106
|
+
async verifyPhone(id) {
|
|
57
107
|
await this.service.verifyPhone(id);
|
|
58
108
|
return {
|
|
109
|
+
success: true,
|
|
59
110
|
message: 'Phone verified successfully'
|
|
60
111
|
};
|
|
61
112
|
}
|
|
62
|
-
|
|
113
|
+
async updateStatus(id, isActive, user) {
|
|
63
114
|
await this.service.updateStatus(id, isActive, user);
|
|
64
115
|
return {
|
|
116
|
+
success: true,
|
|
65
117
|
message: 'Status updated successfully'
|
|
66
118
|
};
|
|
67
119
|
}
|
|
68
|
-
|
|
120
|
+
async profile(dto, user) {
|
|
69
121
|
const data = await this.service.profile(dto, user);
|
|
70
122
|
return {
|
|
123
|
+
success: true,
|
|
71
124
|
message: 'Profile updated successfully',
|
|
72
125
|
data
|
|
73
126
|
};
|
|
74
127
|
}
|
|
128
|
+
async getProfileSections() {
|
|
129
|
+
const sections = await this.service.getProfileSections();
|
|
130
|
+
return {
|
|
131
|
+
success: true,
|
|
132
|
+
message: 'Profile sections retrieved successfully',
|
|
133
|
+
data: sections
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
async getProfileSectionData(id, sectionId, user) {
|
|
137
|
+
const data = await this.service.getProfileSectionData(id, sectionId, user);
|
|
138
|
+
return {
|
|
139
|
+
success: true,
|
|
140
|
+
message: 'Profile section data retrieved successfully',
|
|
141
|
+
data
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
async updateProfileSection(id, sectionId, data, user) {
|
|
145
|
+
await this.service.updateProfileSection(id, sectionId, data, user);
|
|
146
|
+
return {
|
|
147
|
+
success: true,
|
|
148
|
+
message: 'Section updated successfully'
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
async getProfileCompletion(id, user) {
|
|
152
|
+
const percentage = await this.service.getProfileCompletion(id, user);
|
|
153
|
+
return {
|
|
154
|
+
success: true,
|
|
155
|
+
message: 'Profile completion retrieved successfully',
|
|
156
|
+
data: {
|
|
157
|
+
completionPercentage: percentage
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
75
161
|
constructor(service){
|
|
76
162
|
super(service), _define_property(this, "service", void 0), this.service = service;
|
|
77
163
|
}
|
|
78
164
|
};
|
|
165
|
+
_ts_decorate([
|
|
166
|
+
(0, _common.Post)(':id/profile-extras'),
|
|
167
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
168
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
169
|
+
(0, _decorators.RequirePermission)(_classes.USER_PERMISSIONS.READ),
|
|
170
|
+
(0, _swagger.ApiOperation)({
|
|
171
|
+
summary: 'Get user profile with extras',
|
|
172
|
+
description: 'Returns user profile along with extra data (roles, permissions, etc.) if UserEnricher is provided.'
|
|
173
|
+
}),
|
|
174
|
+
(0, _swagger.ApiParam)({
|
|
175
|
+
name: 'id',
|
|
176
|
+
description: 'User ID'
|
|
177
|
+
}),
|
|
178
|
+
_ts_param(0, (0, _common.Param)('id')),
|
|
179
|
+
_ts_param(1, (0, _decorators.CurrentUser)()),
|
|
180
|
+
_ts_metadata("design:type", Function),
|
|
181
|
+
_ts_metadata("design:paramtypes", [
|
|
182
|
+
String,
|
|
183
|
+
typeof _interfaces.ILoggedUserInfo === "undefined" ? Object : _interfaces.ILoggedUserInfo
|
|
184
|
+
]),
|
|
185
|
+
_ts_metadata("design:returntype", Promise)
|
|
186
|
+
], UserController.prototype, "getProfileWithExtras", null);
|
|
79
187
|
_ts_decorate([
|
|
80
188
|
(0, _common.Post)(':id/verify-email'),
|
|
81
189
|
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
82
190
|
(0, _swagger.ApiBearerAuth)(),
|
|
191
|
+
(0, _decorators.RequirePermission)(_classes.USER_PERMISSIONS.UPDATE),
|
|
83
192
|
(0, _swagger.ApiOperation)({
|
|
84
193
|
summary: 'Verify user email'
|
|
85
194
|
}),
|
|
@@ -98,6 +207,7 @@ _ts_decorate([
|
|
|
98
207
|
(0, _common.Post)(':id/verify-phone'),
|
|
99
208
|
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
100
209
|
(0, _swagger.ApiBearerAuth)(),
|
|
210
|
+
(0, _decorators.RequirePermission)(_classes.USER_PERMISSIONS.UPDATE),
|
|
101
211
|
(0, _swagger.ApiOperation)({
|
|
102
212
|
summary: 'Verify user phone'
|
|
103
213
|
}),
|
|
@@ -113,9 +223,10 @@ _ts_decorate([
|
|
|
113
223
|
_ts_metadata("design:returntype", Promise)
|
|
114
224
|
], UserController.prototype, "verifyPhone", null);
|
|
115
225
|
_ts_decorate([
|
|
116
|
-
(0, _common.
|
|
226
|
+
(0, _common.Post)(':id/status'),
|
|
117
227
|
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
118
228
|
(0, _swagger.ApiBearerAuth)(),
|
|
229
|
+
(0, _decorators.RequirePermission)(_classes.USER_PERMISSIONS.UPDATE),
|
|
119
230
|
(0, _swagger.ApiOperation)({
|
|
120
231
|
summary: 'Update user active status',
|
|
121
232
|
description: 'Updates user active status. When company feature is enabled, updates the status for the current company context.'
|
|
@@ -161,6 +272,99 @@ _ts_decorate([
|
|
|
161
272
|
]),
|
|
162
273
|
_ts_metadata("design:returntype", Promise)
|
|
163
274
|
], UserController.prototype, "profile", null);
|
|
275
|
+
_ts_decorate([
|
|
276
|
+
(0, _common.Post)('profile-sections'),
|
|
277
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
278
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
279
|
+
(0, _decorators.RequirePermission)(_classes.USER_PERMISSIONS.READ),
|
|
280
|
+
(0, _swagger.ApiOperation)({
|
|
281
|
+
summary: 'Get profile section definitions',
|
|
282
|
+
description: 'Returns available profile sections for multi-step profile (if enricher configured).'
|
|
283
|
+
}),
|
|
284
|
+
_ts_metadata("design:type", Function),
|
|
285
|
+
_ts_metadata("design:paramtypes", []),
|
|
286
|
+
_ts_metadata("design:returntype", Promise)
|
|
287
|
+
], UserController.prototype, "getProfileSections", null);
|
|
288
|
+
_ts_decorate([
|
|
289
|
+
(0, _common.Post)(':id/profile-section/:sectionId'),
|
|
290
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
291
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
292
|
+
(0, _decorators.RequirePermission)(_classes.USER_PERMISSIONS.READ),
|
|
293
|
+
(0, _swagger.ApiOperation)({
|
|
294
|
+
summary: 'Get profile section data',
|
|
295
|
+
description: 'Returns data for a specific profile section.'
|
|
296
|
+
}),
|
|
297
|
+
(0, _swagger.ApiParam)({
|
|
298
|
+
name: 'id',
|
|
299
|
+
description: 'User ID'
|
|
300
|
+
}),
|
|
301
|
+
(0, _swagger.ApiParam)({
|
|
302
|
+
name: 'sectionId',
|
|
303
|
+
description: 'Section identifier'
|
|
304
|
+
}),
|
|
305
|
+
_ts_param(0, (0, _common.Param)('id')),
|
|
306
|
+
_ts_param(1, (0, _common.Param)('sectionId')),
|
|
307
|
+
_ts_param(2, (0, _decorators.CurrentUser)()),
|
|
308
|
+
_ts_metadata("design:type", Function),
|
|
309
|
+
_ts_metadata("design:paramtypes", [
|
|
310
|
+
String,
|
|
311
|
+
String,
|
|
312
|
+
typeof _interfaces.ILoggedUserInfo === "undefined" ? Object : _interfaces.ILoggedUserInfo
|
|
313
|
+
]),
|
|
314
|
+
_ts_metadata("design:returntype", Promise)
|
|
315
|
+
], UserController.prototype, "getProfileSectionData", null);
|
|
316
|
+
_ts_decorate([
|
|
317
|
+
(0, _common.Post)(':id/profile-section/:sectionId/update'),
|
|
318
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
319
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
320
|
+
(0, _decorators.RequirePermission)(_classes.USER_PERMISSIONS.UPDATE),
|
|
321
|
+
(0, _swagger.ApiOperation)({
|
|
322
|
+
summary: 'Update profile section',
|
|
323
|
+
description: 'Updates a specific profile section data.'
|
|
324
|
+
}),
|
|
325
|
+
(0, _swagger.ApiParam)({
|
|
326
|
+
name: 'id',
|
|
327
|
+
description: 'User ID'
|
|
328
|
+
}),
|
|
329
|
+
(0, _swagger.ApiParam)({
|
|
330
|
+
name: 'sectionId',
|
|
331
|
+
description: 'Section identifier'
|
|
332
|
+
}),
|
|
333
|
+
_ts_param(0, (0, _common.Param)('id')),
|
|
334
|
+
_ts_param(1, (0, _common.Param)('sectionId')),
|
|
335
|
+
_ts_param(2, (0, _common.Body)()),
|
|
336
|
+
_ts_param(3, (0, _decorators.CurrentUser)()),
|
|
337
|
+
_ts_metadata("design:type", Function),
|
|
338
|
+
_ts_metadata("design:paramtypes", [
|
|
339
|
+
String,
|
|
340
|
+
String,
|
|
341
|
+
typeof Record === "undefined" ? Object : Record,
|
|
342
|
+
typeof _interfaces.ILoggedUserInfo === "undefined" ? Object : _interfaces.ILoggedUserInfo
|
|
343
|
+
]),
|
|
344
|
+
_ts_metadata("design:returntype", Promise)
|
|
345
|
+
], UserController.prototype, "updateProfileSection", null);
|
|
346
|
+
_ts_decorate([
|
|
347
|
+
(0, _common.Post)(':id/profile-completion'),
|
|
348
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
349
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
350
|
+
(0, _decorators.RequirePermission)(_classes.USER_PERMISSIONS.READ),
|
|
351
|
+
(0, _swagger.ApiOperation)({
|
|
352
|
+
summary: 'Get profile completion percentage',
|
|
353
|
+
description: 'Returns overall profile completion percentage.'
|
|
354
|
+
}),
|
|
355
|
+
(0, _swagger.ApiParam)({
|
|
356
|
+
name: 'id',
|
|
357
|
+
description: 'User ID'
|
|
358
|
+
}),
|
|
359
|
+
_ts_param(0, (0, _common.Param)('id')),
|
|
360
|
+
_ts_param(1, (0, _decorators.CurrentUser)()),
|
|
361
|
+
_ts_metadata("design:type", Function),
|
|
362
|
+
_ts_metadata("design:paramtypes", [
|
|
363
|
+
String,
|
|
364
|
+
typeof _interfaces.ILoggedUserInfo === "undefined" ? Object : _interfaces.ILoggedUserInfo
|
|
365
|
+
]),
|
|
366
|
+
_ts_metadata("design:returntype", Promise)
|
|
367
|
+
], UserController.prototype, "getProfileCompletion", null);
|
|
164
368
|
UserController = _ts_decorate([
|
|
165
369
|
(0, _swagger.ApiTags)('Users'),
|
|
166
370
|
(0, _common.Controller)('administration/users'),
|
|
@@ -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 {
|
|
@@ -558,16 +576,17 @@ let RegistrationResponseDto = class RegistrationResponseDto {
|
|
|
558
576
|
_define_property(this, "company", void 0);
|
|
559
577
|
_define_property(this, "branch", void 0);
|
|
560
578
|
_define_property(this, "companyFeatureEnabled", void 0);
|
|
579
|
+
_define_property(this, "requiresEmailVerification", void 0);
|
|
561
580
|
}
|
|
562
581
|
};
|
|
563
582
|
_ts_decorate([
|
|
564
|
-
(0, _swagger.
|
|
583
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
565
584
|
example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
|
|
566
585
|
}),
|
|
567
586
|
_ts_metadata("design:type", String)
|
|
568
587
|
], RegistrationResponseDto.prototype, "accessToken", void 0);
|
|
569
588
|
_ts_decorate([
|
|
570
|
-
(0, _swagger.
|
|
589
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
571
590
|
example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
|
|
572
591
|
}),
|
|
573
592
|
_ts_metadata("design:type", String)
|
|
@@ -594,12 +613,19 @@ _ts_decorate([
|
|
|
594
613
|
_ts_metadata("design:type", typeof BranchInfoDto === "undefined" ? Object : BranchInfoDto)
|
|
595
614
|
], RegistrationResponseDto.prototype, "branch", void 0);
|
|
596
615
|
_ts_decorate([
|
|
597
|
-
(0, _swagger.
|
|
616
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
598
617
|
example: true,
|
|
599
618
|
description: 'Whether company feature is enabled'
|
|
600
619
|
}),
|
|
601
620
|
_ts_metadata("design:type", Boolean)
|
|
602
621
|
], RegistrationResponseDto.prototype, "companyFeatureEnabled", void 0);
|
|
622
|
+
_ts_decorate([
|
|
623
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
624
|
+
example: true,
|
|
625
|
+
description: 'Whether email verification is required'
|
|
626
|
+
}),
|
|
627
|
+
_ts_metadata("design:type", Boolean)
|
|
628
|
+
], RegistrationResponseDto.prototype, "requiresEmailVerification", void 0);
|
|
603
629
|
let MeResponseDto = class MeResponseDto {
|
|
604
630
|
constructor(){
|
|
605
631
|
_define_property(this, "user", void 0);
|
|
@@ -674,3 +700,83 @@ _ts_decorate([
|
|
|
674
700
|
}),
|
|
675
701
|
_ts_metadata("design:type", Array)
|
|
676
702
|
], CompanySelectionResponseDto.prototype, "companies", void 0);
|
|
703
|
+
let LoginResponseRequiresEmailVerificationDto = class LoginResponseRequiresEmailVerificationDto {
|
|
704
|
+
constructor(){
|
|
705
|
+
_define_property(this, "requiresEmailVerification", void 0);
|
|
706
|
+
_define_property(this, "email", void 0);
|
|
707
|
+
_define_property(this, "message", void 0);
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
_ts_decorate([
|
|
711
|
+
(0, _swagger.ApiProperty)({
|
|
712
|
+
example: true
|
|
713
|
+
}),
|
|
714
|
+
_ts_metadata("design:type", Boolean)
|
|
715
|
+
], LoginResponseRequiresEmailVerificationDto.prototype, "requiresEmailVerification", void 0);
|
|
716
|
+
_ts_decorate([
|
|
717
|
+
(0, _swagger.ApiProperty)({
|
|
718
|
+
example: 'john@example.com'
|
|
719
|
+
}),
|
|
720
|
+
_ts_metadata("design:type", String)
|
|
721
|
+
], LoginResponseRequiresEmailVerificationDto.prototype, "email", void 0);
|
|
722
|
+
_ts_decorate([
|
|
723
|
+
(0, _swagger.ApiProperty)({
|
|
724
|
+
example: 'Please verify your email address before logging in.'
|
|
725
|
+
}),
|
|
726
|
+
_ts_metadata("design:type", String)
|
|
727
|
+
], LoginResponseRequiresEmailVerificationDto.prototype, "message", void 0);
|
|
728
|
+
let ForgotPasswordDto = class ForgotPasswordDto {
|
|
729
|
+
constructor(){
|
|
730
|
+
_define_property(this, "email", void 0);
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
_ts_decorate([
|
|
734
|
+
(0, _swagger.ApiProperty)({
|
|
735
|
+
example: 'john@example.com',
|
|
736
|
+
description: 'Email address to send reset link to'
|
|
737
|
+
}),
|
|
738
|
+
(0, _classvalidator.IsEmail)(),
|
|
739
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
740
|
+
_ts_metadata("design:type", String)
|
|
741
|
+
], ForgotPasswordDto.prototype, "email", void 0);
|
|
742
|
+
let ResetPasswordDto = class ResetPasswordDto {
|
|
743
|
+
constructor(){
|
|
744
|
+
_define_property(this, "token", void 0);
|
|
745
|
+
_define_property(this, "newPassword", void 0);
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
_ts_decorate([
|
|
749
|
+
(0, _swagger.ApiProperty)({
|
|
750
|
+
example: 'a1b2c3d4e5f6...',
|
|
751
|
+
description: 'Password reset token from email'
|
|
752
|
+
}),
|
|
753
|
+
(0, _classvalidator.IsString)(),
|
|
754
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
755
|
+
_ts_metadata("design:type", String)
|
|
756
|
+
], ResetPasswordDto.prototype, "token", void 0);
|
|
757
|
+
_ts_decorate([
|
|
758
|
+
(0, _swagger.ApiProperty)({
|
|
759
|
+
example: 'NewSecureP@ss123',
|
|
760
|
+
description: 'New password (min 8 chars, requires uppercase, lowercase, number, special char)'
|
|
761
|
+
}),
|
|
762
|
+
(0, _classvalidator.IsString)(),
|
|
763
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
764
|
+
(0, _passwordvalidator.IsStrongPassword)(),
|
|
765
|
+
_ts_metadata("design:type", String)
|
|
766
|
+
], ResetPasswordDto.prototype, "newPassword", void 0);
|
|
767
|
+
let VerifyEmailDto = class VerifyEmailDto {
|
|
768
|
+
constructor(){
|
|
769
|
+
_define_property(this, "token", void 0);
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
_ts_decorate([
|
|
773
|
+
(0, _swagger.ApiProperty)({
|
|
774
|
+
example: 'a1b2c3d4e5f6...',
|
|
775
|
+
description: 'Email verification token from email'
|
|
776
|
+
}),
|
|
777
|
+
(0, _classvalidator.IsString)(),
|
|
778
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
779
|
+
_ts_metadata("design:type", String)
|
|
780
|
+
], VerifyEmailDto.prototype, "token", void 0);
|
|
781
|
+
let ResendVerificationDto = class ResendVerificationDto extends ForgotPasswordDto {
|
|
782
|
+
};
|