@flusys/nestjs-auth 0.1.0-beta.3 → 1.1.0-beta

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 (73) hide show
  1. package/README.md +1 -11
  2. package/cjs/config/auth.constants.js +14 -4
  3. package/cjs/controllers/authentication.controller.js +173 -36
  4. package/cjs/controllers/branch.controller.js +3 -4
  5. package/cjs/controllers/company.controller.js +3 -4
  6. package/cjs/controllers/user-permission.controller.js +6 -18
  7. package/cjs/controllers/user.controller.js +168 -22
  8. package/cjs/dtos/authentication.dto.js +106 -3
  9. package/cjs/entities/index.js +5 -1
  10. package/cjs/entities/pending-registration.entity.js +125 -0
  11. package/cjs/entities/user-token.entity.js +129 -0
  12. package/cjs/interfaces/auth-email-provider.interface.js +45 -0
  13. package/cjs/interfaces/authentication.interface.js +0 -3
  14. package/cjs/interfaces/index.js +2 -0
  15. package/cjs/interfaces/user-enricher.interface.js +4 -0
  16. package/cjs/modules/auth.module.js +8 -2
  17. package/cjs/services/auth-config.service.js +22 -44
  18. package/cjs/services/auth-datasource.provider.js +17 -33
  19. package/cjs/services/auth-email.service.js +452 -0
  20. package/cjs/services/authentication.service.js +229 -115
  21. package/cjs/services/branch.service.js +10 -44
  22. package/cjs/services/company.service.js +7 -36
  23. package/cjs/services/index.js +1 -0
  24. package/cjs/services/user-permission.service.js +9 -27
  25. package/cjs/services/user.service.js +177 -99
  26. package/cjs/strategies/jwt.strategy.js +14 -1
  27. package/config/auth.constants.d.ts +3 -0
  28. package/controllers/authentication.controller.d.ts +13 -9
  29. package/controllers/user.controller.d.ts +27 -0
  30. package/dtos/authentication.dto.d.ts +21 -3
  31. package/dtos/user.dto.d.ts +1 -0
  32. package/entities/index.d.ts +7 -3
  33. package/entities/pending-registration.entity.d.ts +17 -0
  34. package/entities/user-token.entity.d.ts +15 -0
  35. package/fesm/config/auth.constants.js +18 -8
  36. package/fesm/controllers/authentication.controller.js +174 -37
  37. package/fesm/controllers/branch.controller.js +5 -6
  38. package/fesm/controllers/company.controller.js +5 -6
  39. package/fesm/controllers/user-permission.controller.js +6 -18
  40. package/fesm/controllers/user.controller.js +168 -22
  41. package/fesm/dtos/authentication.dto.js +109 -100
  42. package/fesm/entities/index.js +7 -1
  43. package/fesm/entities/pending-registration.entity.js +115 -0
  44. package/fesm/entities/user-token.entity.js +113 -0
  45. package/fesm/interfaces/auth-email-provider.interface.js +38 -0
  46. package/fesm/interfaces/authentication.interface.js +1 -7
  47. package/fesm/interfaces/index.js +2 -0
  48. package/fesm/interfaces/user-enricher.interface.js +26 -0
  49. package/fesm/modules/auth.module.js +9 -3
  50. package/fesm/services/auth-config.service.js +22 -44
  51. package/fesm/services/auth-datasource.provider.js +17 -33
  52. package/fesm/services/auth-email.service.js +401 -0
  53. package/fesm/services/authentication.service.js +227 -113
  54. package/fesm/services/branch.service.js +11 -45
  55. package/fesm/services/company.service.js +8 -37
  56. package/fesm/services/index.js +1 -0
  57. package/fesm/services/user-permission.service.js +9 -27
  58. package/fesm/services/user.service.js +178 -100
  59. package/fesm/strategies/jwt.strategy.js +14 -1
  60. package/interfaces/auth-email-provider.interface.d.ts +6 -0
  61. package/interfaces/auth-module-options.interface.d.ts +4 -1
  62. package/interfaces/authentication.interface.d.ts +14 -0
  63. package/interfaces/index.d.ts +2 -0
  64. package/interfaces/user-enricher.interface.d.ts +67 -0
  65. package/interfaces/user.interface.d.ts +1 -0
  66. package/package.json +3 -3
  67. package/services/auth-config.service.d.ts +1 -0
  68. package/services/auth-email.service.d.ts +50 -0
  69. package/services/authentication.service.d.ts +21 -5
  70. package/services/branch.service.d.ts +2 -5
  71. package/services/company.service.d.ts +1 -4
  72. package/services/index.d.ts +1 -0
  73. package/services/user.service.d.ts +17 -6
package/README.md CHANGED
@@ -763,14 +763,4 @@ The authentication package provides:
763
763
 
764
764
  ---
765
765
 
766
- **Last Updated:** 2026-02-09
767
- **Version:** 4.1.6
768
-
769
- **Recent Improvements:**
770
- - 2026-02-09: Added explicit `@Inject()` decorators to all services for esbuild bundling compatibility
771
- - 2026-02-09: All services now use REQUEST scope with DataSource Provider pattern
772
- - 2026-02-07: Fixed entity diagram to show polymorphic design (permissionType/targetId)
773
- - 2026-02-07: Updated service names to match actual implementation
774
- - 2026-02-07: Simplified login flow diagrams
775
- - 2026-01-15: Fixed JwtStrategy to use `ModuleRef` for request-scoped `AuthDataSourceProvider` resolution
776
- - 2026-01-14: Added `UserPermissionController` for batch permission management
766
+ **Last Updated:** 2026-02-16
@@ -1,7 +1,5 @@
1
- // =============================================================================
2
- // INJECTION TOKENS
3
- // =============================================================================
4
- /** Injection token for auth module options */ "use strict";
1
+ // Injection Tokens
2
+ "use strict";
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
@@ -15,9 +13,21 @@ _export(exports, {
15
13
  get AUTH_MODULE_OPTIONS () {
16
14
  return AUTH_MODULE_OPTIONS;
17
15
  },
16
+ get BCRYPT_SALT_ROUNDS () {
17
+ return BCRYPT_SALT_ROUNDS;
18
+ },
18
19
  get SESSION_CACHE_PREFIX () {
19
20
  return SESSION_CACHE_PREFIX;
21
+ },
22
+ get TOKEN_REVOKED_PREFIX () {
23
+ return TOKEN_REVOKED_PREFIX;
24
+ },
25
+ get USER_ENRICHER () {
26
+ return USER_ENRICHER;
20
27
  }
21
28
  });
22
29
  const AUTH_MODULE_OPTIONS = 'AUTH_MODULE_OPTIONS';
30
+ const USER_ENRICHER = 'USER_ENRICHER';
31
+ const BCRYPT_SALT_ROUNDS = 12;
23
32
  const SESSION_CACHE_PREFIX = 'auth:session';
33
+ const TOKEN_REVOKED_PREFIX = 'auth:revoked';
@@ -15,9 +15,11 @@ const _common = require("@nestjs/common");
15
15
  const _swagger = require("@nestjs/swagger");
16
16
  const _express = require("express");
17
17
  const _authenticationdto = require("../dtos/authentication.dto");
18
+ const _dtos = require("@flusys/nestjs-shared/dtos");
18
19
  const _cleartokeninterceptor = require("../interceptors/clear-token.interceptor");
19
20
  const _settokeninterceptor = require("../interceptors/set-token.interceptor");
20
21
  const _authconfigservice = require("../services/auth-config.service");
22
+ const _authemailservice = require("../services/auth-email.service");
21
23
  const _authenticationservice = require("../services/authentication.service");
22
24
  function _define_property(obj, key, value) {
23
25
  if (key in obj) {
@@ -47,37 +49,27 @@ function _ts_param(paramIndex, decorator) {
47
49
  };
48
50
  }
49
51
  let AuthenticationController = class AuthenticationController {
50
- // ==========================================================================
51
- // CORE ENDPOINTS (Always available)
52
- // ==========================================================================
53
- /**
54
- * Login
55
- * Returns either tokens directly or company/branch selection requirement
56
- * Browser: refreshToken set in HTTP-only cookie, not in response body
57
- * API/Mobile: refreshToken included in response body
58
- */ async login(loginDto) {
52
+ /** Build auth URL for email links */ buildAuthUrl(req, path) {
53
+ const frontendUrl = this.authConfig?.getFrontendUrl();
54
+ return frontendUrl ? `${frontendUrl}${path}` : `${req.protocol}://${req.get('host')}${path}`;
55
+ }
56
+ // Core Endpoints
57
+ /** Login - Returns tokens or company/branch selection requirement */ async login(loginDto) {
59
58
  const result = await this.authService.login(loginDto.email, loginDto.password);
60
59
  if ('requiresSelection' in result) {
61
60
  return result;
62
61
  }
63
62
  return result;
64
63
  }
65
- /**
66
- * Register new user
67
- * If company feature enabled, can optionally join/create company
68
- * Browser: refreshToken set in HTTP-only cookie
69
- */ async register(registrationDto) {
70
- const result = await this.authService.register(registrationDto);
64
+ /** Register new user. If company feature enabled, can join/create company. */ async register(req, registrationDto) {
65
+ const verifyUrlBase = this.buildAuthUrl(req, '/auth/verify-email');
66
+ const result = await this.authService.register(registrationDto, verifyUrlBase);
71
67
  return {
72
68
  ...result,
73
69
  companyFeatureEnabled: this.authConfig?.isCompanyFeatureEnabled() ?? false
74
70
  };
75
71
  }
76
- /**
77
- * Refresh access token
78
- * Browser: Gets refreshToken from HTTP-only cookie
79
- * API/Mobile: Gets refreshToken from request body
80
- */ async refreshToken(req, refreshTokenDto) {
72
+ /** Refresh access token. Browser uses HTTP-only cookie, API/Mobile uses request body. */ async refreshToken(req, refreshTokenDto) {
81
73
  // Get refresh token from cookie (browser) or body (API/mobile)
82
74
  const cookieName = this.authConfig?.getRefreshTokenCookieName() ?? 'fsn_refresh_token';
83
75
  const refreshToken = req.cookies?.[cookieName] || refreshTokenDto.refreshToken;
@@ -86,37 +78,80 @@ let AuthenticationController = class AuthenticationController {
86
78
  }
87
79
  return this.authService.refreshToken(refreshToken);
88
80
  }
89
- /**
90
- * Get current user info
91
- * Returns only user, company, and branch data (no tokens)
92
- * Uses existing access token from Authorization header
93
- * Company/branch fields are automatically excluded from Swagger when company feature is disabled
94
- */ async getCurrentUser(user) {
81
+ /** Get current user info. Returns user, company, and branch data (no tokens). */ async getCurrentUser(user) {
95
82
  return this.authService.getUserInfo(user.id, user.companyId, user.branchId);
96
83
  }
97
- /**
98
- * Logout
99
- * Clears refresh token cookie for browsers
100
- */ async logout(userId) {
84
+ /** Logout - Clears refresh token cookie for browsers */ async logout(userId) {
101
85
  await this.authService.logout(userId);
102
86
  return {
87
+ success: true,
103
88
  message: 'Logged out successfully'
104
89
  };
105
90
  }
106
- /**
107
- * Change password
108
- */ async changePassword(userId, dto) {
91
+ /** Change password */ async changePassword(userId, dto) {
109
92
  await this.authService.changePassword(userId, dto.currentPassword, dto.newPassword);
110
93
  return {
94
+ success: true,
111
95
  message: 'Password changed successfully'
112
96
  };
113
97
  }
98
+ // Email Auth Endpoints
99
+ /** Forgot password - Request password reset email */ async forgotPassword(req, dto) {
100
+ if (!this.authEmailService) {
101
+ return {
102
+ success: false,
103
+ message: 'Email service is not configured'
104
+ };
105
+ }
106
+ return this.authEmailService.forgotPassword(dto.email, this.buildAuthUrl(req, '/auth/reset-password'));
107
+ }
108
+ /** Reset password - Reset password using token */ async resetPassword(dto) {
109
+ if (!this.authEmailService) {
110
+ return {
111
+ success: false,
112
+ message: 'Email service is not configured'
113
+ };
114
+ }
115
+ return this.authEmailService.resetPassword(dto.token, dto.newPassword);
116
+ }
117
+ /** Resend verification email - For unauthenticated users (handles both pending registration and existing users) */ async resendVerification(req, dto) {
118
+ if (!this.authEmailService) {
119
+ return {
120
+ success: false,
121
+ message: 'Email service is not configured'
122
+ };
123
+ }
124
+ return this.authEmailService.resendVerificationEmail(dto.email, this.buildAuthUrl(req, '/auth/verify-email'));
125
+ }
126
+ /** Verify email - Verify email using token. Handles both pending registration and existing user verification. */ async verifyEmail(dto) {
127
+ if (!this.authEmailService) {
128
+ return {
129
+ success: false,
130
+ message: 'Email service is not configured'
131
+ };
132
+ }
133
+ const result = await this.authEmailService.verifyEmail(dto.token);
134
+ if (result.type === 'pending') {
135
+ // Create user from pending registration
136
+ const registrationResult = await this.authService.createUserFromPendingRegistration(result.pending);
137
+ return {
138
+ ...registrationResult,
139
+ companyFeatureEnabled: this.authConfig?.isCompanyFeatureEnabled() ?? false
140
+ };
141
+ }
142
+ return {
143
+ success: true,
144
+ message: result.message
145
+ };
146
+ }
114
147
  // NOTE: @Inject() required for bundled code - type metadata may be lost during esbuild
115
- constructor(authService, authConfig){
148
+ constructor(authService, authConfig, authEmailService){
116
149
  _define_property(this, "authService", void 0);
117
150
  _define_property(this, "authConfig", void 0);
151
+ _define_property(this, "authEmailService", void 0);
118
152
  this.authService = authService;
119
153
  this.authConfig = authConfig;
154
+ this.authEmailService = authEmailService;
120
155
  }
121
156
  };
122
157
  _ts_decorate([
@@ -158,9 +193,11 @@ _ts_decorate([
158
193
  status: 201,
159
194
  type: _authenticationdto.RegistrationResponseDto
160
195
  }),
161
- _ts_param(0, (0, _common.Body)()),
196
+ _ts_param(0, (0, _common.Req)()),
197
+ _ts_param(1, (0, _common.Body)()),
162
198
  _ts_metadata("design:type", Function),
163
199
  _ts_metadata("design:paramtypes", [
200
+ typeof _express.Request === "undefined" ? Object : _express.Request,
164
201
  typeof _authenticationdto.RegistrationDto === "undefined" ? Object : _authenticationdto.RegistrationDto
165
202
  ]),
166
203
  _ts_metadata("design:returntype", Promise)
@@ -210,6 +247,10 @@ _ts_decorate([
210
247
  (0, _swagger.ApiOperation)({
211
248
  summary: 'Logout user'
212
249
  }),
250
+ (0, _swagger.ApiResponse)({
251
+ status: 200,
252
+ type: _dtos.MessageResponseDto
253
+ }),
213
254
  _ts_param(0, (0, _decorators.CurrentUser)('id')),
214
255
  _ts_metadata("design:type", Function),
215
256
  _ts_metadata("design:paramtypes", [
@@ -228,6 +269,10 @@ _ts_decorate([
228
269
  (0, _swagger.ApiBody)({
229
270
  type: _authenticationdto.ChangePasswordDto
230
271
  }),
272
+ (0, _swagger.ApiResponse)({
273
+ status: 200,
274
+ type: _dtos.MessageResponseDto
275
+ }),
231
276
  _ts_param(0, (0, _decorators.CurrentUser)('id')),
232
277
  _ts_param(1, (0, _common.Body)()),
233
278
  _ts_metadata("design:type", Function),
@@ -237,15 +282,107 @@ _ts_decorate([
237
282
  ]),
238
283
  _ts_metadata("design:returntype", Promise)
239
284
  ], AuthenticationController.prototype, "changePassword", null);
285
+ _ts_decorate([
286
+ (0, _common.Post)('forgot-password'),
287
+ (0, _common.HttpCode)(_common.HttpStatus.OK),
288
+ (0, _swagger.ApiOperation)({
289
+ summary: 'Request password reset email'
290
+ }),
291
+ (0, _swagger.ApiBody)({
292
+ type: _authenticationdto.ForgotPasswordDto
293
+ }),
294
+ (0, _swagger.ApiResponse)({
295
+ status: 200,
296
+ type: _dtos.MessageResponseDto
297
+ }),
298
+ _ts_param(0, (0, _common.Req)()),
299
+ _ts_param(1, (0, _common.Body)()),
300
+ _ts_metadata("design:type", Function),
301
+ _ts_metadata("design:paramtypes", [
302
+ typeof _express.Request === "undefined" ? Object : _express.Request,
303
+ typeof _authenticationdto.ForgotPasswordDto === "undefined" ? Object : _authenticationdto.ForgotPasswordDto
304
+ ]),
305
+ _ts_metadata("design:returntype", Promise)
306
+ ], AuthenticationController.prototype, "forgotPassword", null);
307
+ _ts_decorate([
308
+ (0, _common.Post)('reset-password'),
309
+ (0, _common.HttpCode)(_common.HttpStatus.OK),
310
+ (0, _swagger.ApiOperation)({
311
+ summary: 'Reset password using token'
312
+ }),
313
+ (0, _swagger.ApiBody)({
314
+ type: _authenticationdto.ResetPasswordDto
315
+ }),
316
+ (0, _swagger.ApiResponse)({
317
+ status: 200,
318
+ type: _dtos.MessageResponseDto
319
+ }),
320
+ _ts_param(0, (0, _common.Body)()),
321
+ _ts_metadata("design:type", Function),
322
+ _ts_metadata("design:paramtypes", [
323
+ typeof _authenticationdto.ResetPasswordDto === "undefined" ? Object : _authenticationdto.ResetPasswordDto
324
+ ]),
325
+ _ts_metadata("design:returntype", Promise)
326
+ ], AuthenticationController.prototype, "resetPassword", null);
327
+ _ts_decorate([
328
+ (0, _common.Post)('resend-verification'),
329
+ (0, _common.HttpCode)(_common.HttpStatus.OK),
330
+ (0, _swagger.ApiOperation)({
331
+ summary: 'Resend email verification link'
332
+ }),
333
+ (0, _swagger.ApiBody)({
334
+ type: _authenticationdto.ResendVerificationDto
335
+ }),
336
+ (0, _swagger.ApiResponse)({
337
+ status: 200,
338
+ type: _dtos.MessageResponseDto
339
+ }),
340
+ _ts_param(0, (0, _common.Req)()),
341
+ _ts_param(1, (0, _common.Body)()),
342
+ _ts_metadata("design:type", Function),
343
+ _ts_metadata("design:paramtypes", [
344
+ typeof _express.Request === "undefined" ? Object : _express.Request,
345
+ typeof _authenticationdto.ResendVerificationDto === "undefined" ? Object : _authenticationdto.ResendVerificationDto
346
+ ]),
347
+ _ts_metadata("design:returntype", Promise)
348
+ ], AuthenticationController.prototype, "resendVerification", null);
349
+ _ts_decorate([
350
+ (0, _common.Post)('verify-email'),
351
+ (0, _common.HttpCode)(_common.HttpStatus.OK),
352
+ (0, _common.UseInterceptors)(_settokeninterceptor.SetToken),
353
+ (0, _swagger.ApiOperation)({
354
+ summary: 'Verify email using token'
355
+ }),
356
+ (0, _swagger.ApiBody)({
357
+ type: _authenticationdto.VerifyEmailDto
358
+ }),
359
+ (0, _swagger.ApiResponse)({
360
+ status: 200,
361
+ type: _dtos.MessageResponseDto
362
+ }),
363
+ (0, _swagger.ApiResponse)({
364
+ status: 200,
365
+ type: _authenticationdto.RegistrationResponseDto
366
+ }),
367
+ _ts_param(0, (0, _common.Body)()),
368
+ _ts_metadata("design:type", Function),
369
+ _ts_metadata("design:paramtypes", [
370
+ typeof _authenticationdto.VerifyEmailDto === "undefined" ? Object : _authenticationdto.VerifyEmailDto
371
+ ]),
372
+ _ts_metadata("design:returntype", Promise)
373
+ ], AuthenticationController.prototype, "verifyEmail", null);
240
374
  AuthenticationController = _ts_decorate([
241
375
  (0, _swagger.ApiTags)('Authentication'),
242
376
  (0, _common.Controller)('auth'),
243
377
  _ts_param(0, (0, _common.Inject)(_authenticationservice.AuthenticationService)),
244
378
  _ts_param(1, (0, _common.Optional)()),
245
379
  _ts_param(1, (0, _common.Inject)(_authconfigservice.AuthConfigService)),
380
+ _ts_param(2, (0, _common.Optional)()),
381
+ _ts_param(2, (0, _common.Inject)(_authemailservice.AuthEmailService)),
246
382
  _ts_metadata("design:type", Function),
247
383
  _ts_metadata("design:paramtypes", [
248
384
  typeof _authenticationservice.AuthenticationService === "undefined" ? Object : _authenticationservice.AuthenticationService,
249
- typeof _authconfigservice.AuthConfigService === "undefined" ? Object : _authconfigservice.AuthConfigService
385
+ typeof _authconfigservice.AuthConfigService === "undefined" ? Object : _authconfigservice.AuthConfigService,
386
+ typeof _authemailservice.AuthEmailService === "undefined" ? Object : _authemailservice.AuthEmailService
250
387
  ])
251
388
  ], AuthenticationController);
@@ -12,7 +12,6 @@ const _classes = require("@flusys/nestjs-shared/classes");
12
12
  const _common = require("@nestjs/common");
13
13
  const _swagger = require("@nestjs/swagger");
14
14
  const _companybranchdto = require("../dtos/company-branch.dto");
15
- const _guards = require("@flusys/nestjs-shared/guards");
16
15
  const _branchservice = require("../services/branch.service");
17
16
  function _define_property(obj, key, value) {
18
17
  if (key in obj) {
@@ -41,16 +40,16 @@ function _ts_param(paramIndex, decorator) {
41
40
  decorator(target, key, paramIndex);
42
41
  };
43
42
  }
44
- let BranchController = class BranchController extends (0, _classes.createApiController)(_companybranchdto.CreateCompanyBranchDto, _companybranchdto.UpdateCompanyBranchDto, _companybranchdto.CompanyBranchResponseDto) {
43
+ let BranchController = class BranchController extends (0, _classes.createApiController)(_companybranchdto.CreateCompanyBranchDto, _companybranchdto.UpdateCompanyBranchDto, _companybranchdto.CompanyBranchResponseDto, {
44
+ security: 'jwt'
45
+ }) {
45
46
  constructor(branchService){
46
47
  super(branchService), _define_property(this, "branchService", void 0), this.branchService = branchService;
47
48
  }
48
49
  };
49
50
  BranchController = _ts_decorate([
50
51
  (0, _swagger.ApiTags)('Branches'),
51
- (0, _swagger.ApiBearerAuth)(),
52
52
  (0, _common.Controller)('administration/branch'),
53
- (0, _common.UseGuards)(_guards.JwtAuthGuard),
54
53
  _ts_param(0, (0, _common.Inject)(_branchservice.BranchService)),
55
54
  _ts_metadata("design:type", Function),
56
55
  _ts_metadata("design:paramtypes", [
@@ -12,7 +12,6 @@ const _classes = require("@flusys/nestjs-shared/classes");
12
12
  const _common = require("@nestjs/common");
13
13
  const _swagger = require("@nestjs/swagger");
14
14
  const _companydto = require("../dtos/company.dto");
15
- const _guards = require("@flusys/nestjs-shared/guards");
16
15
  const _companyservice = require("../services/company.service");
17
16
  function _define_property(obj, key, value) {
18
17
  if (key in obj) {
@@ -41,16 +40,16 @@ function _ts_param(paramIndex, decorator) {
41
40
  decorator(target, key, paramIndex);
42
41
  };
43
42
  }
44
- let CompanyController = class CompanyController extends (0, _classes.createApiController)(_companydto.CreateCompanyDto, _companydto.UpdateCompanyDto, _companydto.CompanyResponseDto) {
43
+ let CompanyController = class CompanyController extends (0, _classes.createApiController)(_companydto.CreateCompanyDto, _companydto.UpdateCompanyDto, _companydto.CompanyResponseDto, {
44
+ security: 'jwt'
45
+ }) {
45
46
  constructor(companyService){
46
47
  super(companyService), _define_property(this, "companyService", void 0), this.companyService = companyService;
47
48
  }
48
49
  };
49
50
  CompanyController = _ts_decorate([
50
51
  (0, _swagger.ApiTags)('Companies'),
51
- (0, _swagger.ApiBearerAuth)(),
52
52
  (0, _common.Controller)('administration/company'),
53
- (0, _common.UseGuards)(_guards.JwtAuthGuard),
54
53
  _ts_param(0, (0, _common.Inject)(_companyservice.CompanyService)),
55
54
  _ts_metadata("design:type", Function),
56
55
  _ts_metadata("design:paramtypes", [
@@ -41,12 +41,8 @@ function _ts_param(paramIndex, decorator) {
41
41
  };
42
42
  }
43
43
  let UserPermissionController = class UserPermissionController {
44
- // ========================================================================
45
- // USER-COMPANY PERMISSIONS
46
- // ========================================================================
47
- /**
48
- * Batch assign/revoke user-company permissions
49
- */ async assignUserCompany(dto) {
44
+ // User-Company Permissions
45
+ /** Batch assign/revoke user-company permissions */ async assignUserCompany(dto) {
50
46
  let addedCount = 0;
51
47
  let removedCount = 0;
52
48
  for (const item of dto.items){
@@ -66,9 +62,7 @@ let UserPermissionController = class UserPermissionController {
66
62
  message: `Processed ${addedCount} additions and ${removedCount} removals`
67
63
  };
68
64
  }
69
- /**
70
- * Get user's companies
71
- */ async getUserCompanies(userId) {
65
+ /** Get user's companies */ async getUserCompanies(userId) {
72
66
  const permissions = await this.userPermissionService.findUserCompanies(userId);
73
67
  // Map to DTO format with populated company details
74
68
  const data = permissions.map((permission)=>({
@@ -82,12 +76,8 @@ let UserPermissionController = class UserPermissionController {
82
76
  data
83
77
  };
84
78
  }
85
- // ========================================================================
86
- // USER-BRANCH PERMISSIONS
87
- // ========================================================================
88
- /**
89
- * Batch assign/revoke user-branch permissions
90
- */ async assignUserBranch(dto) {
79
+ // User-Branch Permissions
80
+ /** Batch assign/revoke user-branch permissions */ async assignUserBranch(dto) {
91
81
  let addedCount = 0;
92
82
  let removedCount = 0;
93
83
  for (const item of dto.items){
@@ -107,9 +97,7 @@ let UserPermissionController = class UserPermissionController {
107
97
  message: `Processed ${addedCount} additions and ${removedCount} removals`
108
98
  };
109
99
  }
110
- /**
111
- * Get user's branches
112
- */ async getUserBranches(userId) {
100
+ /** Get user's branches */ async getUserBranches(userId) {
113
101
  const permissions = await this.userPermissionService.findUserBranches(userId);
114
102
  // Map to DTO format with populated branch details
115
103
  const data = permissions.map((permission)=>({