@flusys/nestjs-auth 1.1.0-beta → 2.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.
Files changed (86) hide show
  1. package/README.md +590 -473
  2. package/cjs/config/auth.constants.js +8 -0
  3. package/cjs/controllers/authentication.controller.js +218 -39
  4. package/cjs/controllers/branch.controller.js +44 -1
  5. package/cjs/controllers/company-selection.controller.js +27 -20
  6. package/cjs/controllers/company.controller.js +44 -1
  7. package/cjs/controllers/user-permission.controller.js +82 -154
  8. package/cjs/controllers/user.controller.js +68 -15
  9. package/cjs/docs/auth-swagger.config.js +14 -7
  10. package/cjs/dtos/authentication.dto.js +16 -43
  11. package/cjs/dtos/index.js +0 -1
  12. package/cjs/dtos/user-permission.dto.js +28 -0
  13. package/cjs/dtos/user.dto.js +19 -4
  14. package/cjs/entities/user-company-permission.entity.js +0 -6
  15. package/cjs/interceptors/clear-token.interceptor.js +10 -23
  16. package/cjs/interceptors/set-token.interceptor.js +15 -55
  17. package/cjs/interfaces/auth-email-provider.interface.js +1 -1
  18. package/cjs/modules/auth.module.js +63 -147
  19. package/cjs/services/auth-config.service.js +22 -28
  20. package/cjs/services/auth-datasource.provider.js +9 -21
  21. package/cjs/services/auth-email.service.js +89 -85
  22. package/cjs/services/authentication.service.js +225 -396
  23. package/cjs/services/branch.service.js +9 -4
  24. package/cjs/services/company-selection-session.service.js +1 -1
  25. package/cjs/services/user-permission.service.js +43 -73
  26. package/cjs/services/user.service.js +78 -64
  27. package/cjs/strategies/jwt.strategy.js +44 -44
  28. package/cjs/validators/password.validator.js +45 -0
  29. package/config/auth.constants.d.ts +2 -0
  30. package/controllers/authentication.controller.d.ts +5 -3
  31. package/controllers/company-selection.controller.d.ts +6 -2
  32. package/controllers/user-permission.controller.d.ts +5 -4
  33. package/controllers/user.controller.d.ts +6 -0
  34. package/dtos/authentication.dto.d.ts +0 -4
  35. package/dtos/company-branch.dto.d.ts +0 -1
  36. package/dtos/company.dto.d.ts +0 -1
  37. package/dtos/index.d.ts +0 -1
  38. package/dtos/user-permission.dto.d.ts +4 -0
  39. package/dtos/user.dto.d.ts +1 -3
  40. package/entities/index.d.ts +3 -3
  41. package/entities/user-company-permission.entity.d.ts +0 -2
  42. package/fesm/config/auth.constants.js +6 -13
  43. package/fesm/controllers/authentication.controller.js +221 -42
  44. package/fesm/controllers/branch.controller.js +45 -2
  45. package/fesm/controllers/company-selection.controller.js +28 -21
  46. package/fesm/controllers/company.controller.js +45 -2
  47. package/fesm/controllers/user-permission.controller.js +84 -156
  48. package/fesm/controllers/user.controller.js +71 -18
  49. package/fesm/docs/auth-swagger.config.js +14 -7
  50. package/fesm/dtos/authentication.dto.js +17 -44
  51. package/fesm/dtos/index.js +0 -1
  52. package/fesm/dtos/user-permission.dto.js +28 -0
  53. package/fesm/dtos/user.dto.js +20 -5
  54. package/fesm/entities/user-company-permission.entity.js +0 -6
  55. package/fesm/interceptors/clear-token.interceptor.js +9 -22
  56. package/fesm/interceptors/set-token.interceptor.js +14 -54
  57. package/fesm/interfaces/auth-email-provider.interface.js +1 -1
  58. package/fesm/modules/auth.module.js +64 -148
  59. package/fesm/services/auth-config.service.js +23 -29
  60. package/fesm/services/auth-datasource.provider.js +10 -22
  61. package/fesm/services/auth-email.service.js +90 -86
  62. package/fesm/services/authentication.service.js +225 -396
  63. package/fesm/services/branch.service.js +9 -4
  64. package/fesm/services/company-selection-session.service.js +1 -1
  65. package/fesm/services/user-permission.service.js +44 -74
  66. package/fesm/services/user.service.js +79 -65
  67. package/fesm/strategies/jwt.strategy.js +44 -44
  68. package/fesm/validators/password.validator.js +48 -0
  69. package/interceptors/clear-token.interceptor.d.ts +0 -1
  70. package/interceptors/set-token.interceptor.d.ts +1 -1
  71. package/interfaces/authentication.interface.d.ts +0 -4
  72. package/interfaces/user-enricher.interface.d.ts +1 -4
  73. package/modules/auth.module.d.ts +6 -3
  74. package/package.json +4 -4
  75. package/services/auth-config.service.d.ts +6 -8
  76. package/services/auth-datasource.provider.d.ts +2 -4
  77. package/services/auth-email.service.d.ts +8 -4
  78. package/services/authentication.service.d.ts +15 -16
  79. package/services/company-selection-session.service.d.ts +1 -1
  80. package/services/user-permission.service.d.ts +6 -9
  81. package/services/user.service.d.ts +3 -0
  82. package/strategies/jwt.strategy.d.ts +4 -1
  83. package/validators/password.validator.d.ts +10 -0
  84. package/cjs/dtos/user-company-permission.dto.js +0 -110
  85. package/dtos/user-company-permission.dto.d.ts +0 -10
  86. package/fesm/dtos/user-company-permission.dto.js +0 -98
@@ -8,10 +8,11 @@ Object.defineProperty(exports, "UserPermissionController", {
8
8
  return UserPermissionController;
9
9
  }
10
10
  });
11
+ const _nestjsshared = require("@flusys/nestjs-shared");
11
12
  const _common = require("@nestjs/common");
12
13
  const _swagger = require("@nestjs/swagger");
13
- const _guards = require("@flusys/nestjs-shared/guards");
14
14
  const _userpermissiondto = require("../dtos/user-permission.dto");
15
+ const _usercompanypermissionentity = require("../entities/user-company-permission.entity");
15
16
  const _userpermissionservice = require("../services/user-permission.service");
16
17
  function _define_property(obj, key, value) {
17
18
  if (key in obj) {
@@ -41,123 +42,67 @@ function _ts_param(paramIndex, decorator) {
41
42
  };
42
43
  }
43
44
  let UserPermissionController = class UserPermissionController {
44
- // User-Company Permissions
45
- /** Batch assign/revoke user-company permissions */ async assignUserCompany(dto) {
46
- let addedCount = 0;
47
- let removedCount = 0;
48
- for (const item of dto.items){
49
- if (item.isAdd) {
50
- await this.userPermissionService.assignUserToCompany({
51
- userId: dto.userId,
52
- companyId: item.targetId
53
- });
54
- addedCount++;
55
- } else {
56
- await this.userPermissionService.revokeCompanyAccess(dto.userId, item.targetId);
57
- removedCount++;
58
- }
59
- }
45
+ async assignUserCompany(dto) {
46
+ return this.processBatchPermissions(dto.userId, dto.items, _usercompanypermissionentity.PermissionType.COMPANY);
47
+ }
48
+ async getUserCompanies(userId) {
49
+ const permissions = await this.permissionService.findUserCompanies(userId);
60
50
  return {
61
51
  success: true,
62
- message: `Processed ${addedCount} additions and ${removedCount} removals`
52
+ message: 'User companies retrieved successfully',
53
+ data: permissions.map((p)=>({
54
+ id: p.id,
55
+ userId: p.userId,
56
+ companyId: p.company?.id || p.targetId,
57
+ companyName: p.company?.name || '',
58
+ companySlug: p.company?.slug || ''
59
+ }))
63
60
  };
64
61
  }
65
- /** Get user's companies */ async getUserCompanies(userId) {
66
- const permissions = await this.userPermissionService.findUserCompanies(userId);
67
- // Map to DTO format with populated company details
68
- const data = permissions.map((permission)=>({
69
- id: permission.id,
70
- userId: permission.userId,
71
- companyId: permission.company?.id || permission.targetId,
72
- companyName: permission.company?.name || '',
73
- companySlug: permission.company?.slug || ''
74
- }));
62
+ async assignUserBranch(dto) {
63
+ return this.processBatchPermissions(dto.userId, dto.items, _usercompanypermissionentity.PermissionType.BRANCH);
64
+ }
65
+ async getUserBranches(userId, companyId) {
66
+ const permissions = await this.permissionService.findUserBranches(userId, companyId);
75
67
  return {
76
- data
68
+ success: true,
69
+ message: 'User branches retrieved successfully',
70
+ data: permissions.map((p)=>({
71
+ id: p.id,
72
+ userId: p.userId,
73
+ branchId: p.branch?.id || p.targetId,
74
+ branchName: p.branch?.name || '',
75
+ branchSlug: p.branch?.slug || '',
76
+ companyId: p.branch?.companyId || ''
77
+ }))
77
78
  };
78
79
  }
79
- // User-Branch Permissions
80
- /** Batch assign/revoke user-branch permissions */ async assignUserBranch(dto) {
81
- let addedCount = 0;
82
- let removedCount = 0;
83
- for (const item of dto.items){
80
+ /** Process batch permission assignments/revocations */ async processBatchPermissions(userId, items, type) {
81
+ let added = 0, removed = 0;
82
+ for (const item of items){
84
83
  if (item.isAdd) {
85
- await this.userPermissionService.assignUserToBranch({
86
- userId: dto.userId,
87
- branchId: item.targetId
88
- });
89
- addedCount++;
84
+ await this.permissionService.assignPermission(userId, item.targetId, type);
85
+ added++;
90
86
  } else {
91
- await this.userPermissionService.revokeBranchAccess(dto.userId, item.targetId);
92
- removedCount++;
87
+ await this.permissionService.revokePermission(userId, item.targetId, type);
88
+ removed++;
93
89
  }
94
90
  }
95
91
  return {
96
92
  success: true,
97
- message: `Processed ${addedCount} additions and ${removedCount} removals`
98
- };
99
- }
100
- /** Get user's branches */ async getUserBranches(userId) {
101
- const permissions = await this.userPermissionService.findUserBranches(userId);
102
- // Map to DTO format with populated branch details
103
- const data = permissions.map((permission)=>({
104
- id: permission.id,
105
- userId: permission.userId,
106
- branchId: permission.branch?.id || permission.targetId,
107
- branchName: permission.branch?.name || '',
108
- branchSlug: permission.branch?.slug || '',
109
- companyId: permission.branch?.companyId || ''
110
- }));
111
- return {
112
- data
93
+ message: `Processed ${added} additions and ${removed} removals`
113
94
  };
114
95
  }
115
- // NOTE: @Inject() required for bundled code - type metadata may be lost during esbuild
116
- constructor(userPermissionService){
117
- _define_property(this, "userPermissionService", void 0);
118
- this.userPermissionService = userPermissionService;
96
+ constructor(permissionService){
97
+ _define_property(this, "permissionService", void 0);
98
+ this.permissionService = permissionService;
119
99
  }
120
100
  };
121
101
  _ts_decorate([
122
102
  (0, _common.Post)('user-company/assign'),
103
+ (0, _nestjsshared.RequirePermission)(_nestjsshared.USER_PERMISSIONS.UPDATE),
123
104
  (0, _swagger.ApiOperation)({
124
- summary: 'Batch assign/revoke user-company permissions',
125
- description: `
126
- Batch operation to assign or revoke user permissions to companies.
127
-
128
- **Example: Add company permissions**
129
- \`\`\`json
130
- {
131
- "userId": "user-id",
132
- "items": [
133
- { "targetId": "company-id-1", "isAdd": true },
134
- { "targetId": "company-id-2", "isAdd": true }
135
- ]
136
- }
137
- \`\`\`
138
-
139
- **Example: Remove company permissions**
140
- \`\`\`json
141
- {
142
- "userId": "user-id",
143
- "items": [
144
- { "targetId": "company-id-1", "isAdd": false },
145
- { "targetId": "company-id-2", "isAdd": false }
146
- ]
147
- }
148
- \`\`\`
149
-
150
- **Example: Mix add and remove**
151
- \`\`\`json
152
- {
153
- "userId": "user-id",
154
- "items": [
155
- { "targetId": "company-id-1", "isAdd": true },
156
- { "targetId": "company-id-2", "isAdd": false }
157
- ]
158
- }
159
- \`\`\`
160
- `
105
+ summary: 'Batch assign/revoke user-company permissions'
161
106
  }),
162
107
  (0, _swagger.ApiResponse)({
163
108
  status: 200,
@@ -174,22 +119,28 @@ Batch operation to assign or revoke user permissions to companies.
174
119
  _ts_metadata("design:returntype", Promise)
175
120
  ], UserPermissionController.prototype, "assignUserCompany", null);
176
121
  _ts_decorate([
177
- (0, _common.Get)('user-company'),
122
+ (0, _common.Post)('get-user-company'),
123
+ (0, _nestjsshared.RequirePermission)(_nestjsshared.USER_PERMISSIONS.READ),
178
124
  (0, _swagger.ApiOperation)({
179
- summary: 'Get user companies',
180
- description: 'Returns all companies the user has access to.'
125
+ summary: 'Get user companies'
181
126
  }),
182
- (0, _swagger.ApiQuery)({
183
- name: 'userId',
184
- required: true,
185
- description: 'User ID to get companies for',
186
- example: '550e8400-e29b-41d4-a716-446655440000'
127
+ (0, _swagger.ApiBody)({
128
+ schema: {
129
+ properties: {
130
+ userId: {
131
+ type: 'string'
132
+ }
133
+ },
134
+ required: [
135
+ 'userId'
136
+ ]
137
+ }
187
138
  }),
188
139
  (0, _swagger.ApiResponse)({
189
140
  status: 200,
190
141
  type: _userpermissiondto.UserCompaniesResponseDto
191
142
  }),
192
- _ts_param(0, (0, _common.Query)('userId')),
143
+ _ts_param(0, (0, _common.Body)('userId')),
193
144
  _ts_metadata("design:type", Function),
194
145
  _ts_metadata("design:paramtypes", [
195
146
  String
@@ -198,44 +149,9 @@ _ts_decorate([
198
149
  ], UserPermissionController.prototype, "getUserCompanies", null);
199
150
  _ts_decorate([
200
151
  (0, _common.Post)('user-branch/assign'),
152
+ (0, _nestjsshared.RequirePermission)(_nestjsshared.USER_PERMISSIONS.UPDATE),
201
153
  (0, _swagger.ApiOperation)({
202
- summary: 'Batch assign/revoke user-branch permissions',
203
- description: `
204
- Batch operation to assign or revoke user permissions to branches.
205
-
206
- **Example: Add branch permissions**
207
- \`\`\`json
208
- {
209
- "userId": "user-id",
210
- "items": [
211
- { "targetId": "branch-id-1", "isAdd": true },
212
- { "targetId": "branch-id-2", "isAdd": true }
213
- ]
214
- }
215
- \`\`\`
216
-
217
- **Example: Remove branch permissions**
218
- \`\`\`json
219
- {
220
- "userId": "user-id",
221
- "items": [
222
- { "targetId": "branch-id-1", "isAdd": false },
223
- { "targetId": "branch-id-2", "isAdd": false }
224
- ]
225
- }
226
- \`\`\`
227
-
228
- **Example: Mix add and remove**
229
- \`\`\`json
230
- {
231
- "userId": "user-id",
232
- "items": [
233
- { "targetId": "branch-id-1", "isAdd": true },
234
- { "targetId": "branch-id-2", "isAdd": false }
235
- ]
236
- }
237
- \`\`\`
238
- `
154
+ summary: 'Batch assign/revoke user-branch permissions'
239
155
  }),
240
156
  (0, _swagger.ApiResponse)({
241
157
  status: 200,
@@ -252,24 +168,36 @@ Batch operation to assign or revoke user permissions to branches.
252
168
  _ts_metadata("design:returntype", Promise)
253
169
  ], UserPermissionController.prototype, "assignUserBranch", null);
254
170
  _ts_decorate([
255
- (0, _common.Get)('user-branch'),
171
+ (0, _common.Post)('get-user-branch'),
172
+ (0, _nestjsshared.RequirePermission)(_nestjsshared.USER_PERMISSIONS.READ),
256
173
  (0, _swagger.ApiOperation)({
257
- summary: 'Get user branches',
258
- description: 'Returns all branches the user has access to.'
174
+ summary: 'Get user branches'
259
175
  }),
260
- (0, _swagger.ApiQuery)({
261
- name: 'userId',
262
- required: true,
263
- description: 'User ID to get branches for',
264
- example: '550e8400-e29b-41d4-a716-446655440000'
176
+ (0, _swagger.ApiBody)({
177
+ schema: {
178
+ properties: {
179
+ userId: {
180
+ type: 'string'
181
+ },
182
+ companyId: {
183
+ type: 'string',
184
+ description: 'Optional company ID to filter branches'
185
+ }
186
+ },
187
+ required: [
188
+ 'userId'
189
+ ]
190
+ }
265
191
  }),
266
192
  (0, _swagger.ApiResponse)({
267
193
  status: 200,
268
194
  type: _userpermissiondto.UserBranchesResponseDto
269
195
  }),
270
- _ts_param(0, (0, _common.Query)('userId')),
196
+ _ts_param(0, (0, _common.Body)('userId')),
197
+ _ts_param(1, (0, _common.Body)('companyId')),
271
198
  _ts_metadata("design:type", Function),
272
199
  _ts_metadata("design:paramtypes", [
200
+ String,
273
201
  String
274
202
  ]),
275
203
  _ts_metadata("design:returntype", Promise)
@@ -278,7 +206,7 @@ UserPermissionController = _ts_decorate([
278
206
  (0, _swagger.ApiTags)('User Permissions'),
279
207
  (0, _swagger.ApiBearerAuth)(),
280
208
  (0, _common.Controller)('administration/permissions'),
281
- (0, _common.UseGuards)(_guards.JwtAuthGuard),
209
+ (0, _common.UseGuards)(_nestjsshared.JwtAuthGuard),
282
210
  _ts_param(0, (0, _common.Inject)(_userpermissionservice.UserPermissionService)),
283
211
  _ts_metadata("design:type", Function),
284
212
  _ts_metadata("design:paramtypes", [
@@ -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: 'jwt'
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
- // Custom Endpoints
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
- /** Verify user email */ async verifyEmail(id) {
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
- /** Verify user phone */ async verifyPhone(id) {
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
- /** Update user active status. When company feature enabled, updates permission isActive for logged user's company. */ async updateStatus(id, isActive, user) {
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
- /** Update user profile */ async profile(dto, user) {
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
- /** Get specific profile section data */ async getProfileSectionData(id, sectionId, user) {
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
- /** Update specific profile section */ async updateProfileSection(id, sectionId, data, user) {
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
- /** Get profile completion percentage */ async getProfileCompletion(id, user) {
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.Put)(':id/status'),
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
  }