@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
@@ -31,12 +31,8 @@ import { JwtAuthGuard } from '@flusys/nestjs-shared/guards';
31
31
  import { AssignUserCompanyDto, AssignUserBranchDto, UserCompaniesResponseDto, UserBranchesResponseDto } from '../dtos/user-permission.dto';
32
32
  import { UserPermissionService } from '../services/user-permission.service';
33
33
  export class UserPermissionController {
34
- // ========================================================================
35
- // USER-COMPANY PERMISSIONS
36
- // ========================================================================
37
- /**
38
- * Batch assign/revoke user-company permissions
39
- */ async assignUserCompany(dto) {
34
+ // User-Company Permissions
35
+ /** Batch assign/revoke user-company permissions */ async assignUserCompany(dto) {
40
36
  let addedCount = 0;
41
37
  let removedCount = 0;
42
38
  for (const item of dto.items){
@@ -56,9 +52,7 @@ export class UserPermissionController {
56
52
  message: `Processed ${addedCount} additions and ${removedCount} removals`
57
53
  };
58
54
  }
59
- /**
60
- * Get user's companies
61
- */ async getUserCompanies(userId) {
55
+ /** Get user's companies */ async getUserCompanies(userId) {
62
56
  const permissions = await this.userPermissionService.findUserCompanies(userId);
63
57
  // Map to DTO format with populated company details
64
58
  const data = permissions.map((permission)=>({
@@ -72,12 +66,8 @@ export class UserPermissionController {
72
66
  data
73
67
  };
74
68
  }
75
- // ========================================================================
76
- // USER-BRANCH PERMISSIONS
77
- // ========================================================================
78
- /**
79
- * Batch assign/revoke user-branch permissions
80
- */ async assignUserBranch(dto) {
69
+ // User-Branch Permissions
70
+ /** Batch assign/revoke user-branch permissions */ async assignUserBranch(dto) {
81
71
  let addedCount = 0;
82
72
  let removedCount = 0;
83
73
  for (const item of dto.items){
@@ -97,9 +87,7 @@ export class UserPermissionController {
97
87
  message: `Processed ${addedCount} additions and ${removedCount} removals`
98
88
  };
99
89
  }
100
- /**
101
- * Get user's branches
102
- */ async getUserBranches(userId) {
90
+ /** Get user's branches */ async getUserBranches(userId) {
103
91
  const permissions = await this.userPermissionService.findUserBranches(userId);
104
92
  // Map to DTO format with populated branch details
105
93
  const data = permissions.map((permission)=>({
@@ -27,58 +27,111 @@ function _ts_param(paramIndex, decorator) {
27
27
  }
28
28
  import { createApiController } from '@flusys/nestjs-shared/classes';
29
29
  import { CurrentUser } from '@flusys/nestjs-shared/decorators';
30
+ import { JwtAuthGuard } from '@flusys/nestjs-shared/guards';
30
31
  import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
31
32
  import { Body, Controller, Inject, Param, Post, Put, UseGuards } from '@nestjs/common';
32
33
  import { ApiBearerAuth, ApiBody, ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger';
33
34
  import { CreateUserDto, UpdateUserDto, UserResponseDto } from '../dtos/user.dto';
34
- import { JwtAuthGuard } from '@flusys/nestjs-shared/guards';
35
35
  import { UserService } from '../services/user.service';
36
- export class UserController extends createApiController(CreateUserDto, UpdateUserDto, UserResponseDto) {
37
- // ==========================================================================
38
- // CUSTOM ENDPOINTS (Beyond standard CRUD)
39
- // ==========================================================================
40
- /**
41
- * Verify user email
42
- */ async verifyEmail(id) {
36
+ export class UserController extends createApiController(CreateUserDto, UpdateUserDto, UserResponseDto, {
37
+ security: 'jwt'
38
+ }) {
39
+ // Custom Endpoints
40
+ /** Get user profile with extras (roles, permissions, etc.) from enricher */ async getProfileWithExtras(id, user) {
41
+ const data = await this.service.getProfileWithExtras(id, user);
42
+ return {
43
+ success: true,
44
+ data
45
+ };
46
+ }
47
+ /** Verify user email */ async verifyEmail(id) {
43
48
  await this.service.verifyEmail(id);
44
49
  return {
45
50
  message: 'Email verified successfully'
46
51
  };
47
52
  }
48
- /**
49
- * Verify user phone
50
- */ async verifyPhone(id) {
53
+ /** Verify user phone */ async verifyPhone(id) {
51
54
  await this.service.verifyPhone(id);
52
55
  return {
53
56
  message: 'Phone verified successfully'
54
57
  };
55
58
  }
56
- /**
57
- * Update user active status
58
- *
59
- * When company feature is disabled: Updates User.isActive directly
60
- * When company feature is enabled: Updates UserCompanyPermission.isActive for logged user's company
61
- */ async updateStatus(id, isActive, user) {
59
+ /** Update user active status. When company feature enabled, updates permission isActive for logged user's company. */ async updateStatus(id, isActive, user) {
62
60
  await this.service.updateStatus(id, isActive, user);
63
61
  return {
64
62
  message: 'Status updated successfully'
65
63
  };
66
64
  }
67
- /**
68
- * Update user profile
69
- */ async profile(dto, user) {
65
+ /** Update user profile */ async profile(dto, user) {
70
66
  const data = await this.service.profile(dto, user);
71
67
  return {
68
+ success: true,
72
69
  message: 'Profile updated successfully',
73
70
  data
74
71
  };
75
72
  }
73
+ // ============================================
74
+ // Multi-Step Profile Endpoints (via Enricher)
75
+ // ============================================
76
+ /** Get profile section definitions */ async getProfileSections() {
77
+ const sections = await this.service.getProfileSections();
78
+ return {
79
+ success: true,
80
+ data: sections
81
+ };
82
+ }
83
+ /** Get specific profile section data */ async getProfileSectionData(id, sectionId, user) {
84
+ const data = await this.service.getProfileSectionData(id, sectionId, user);
85
+ return {
86
+ success: true,
87
+ data
88
+ };
89
+ }
90
+ /** Update specific profile section */ async updateProfileSection(id, sectionId, data, user) {
91
+ await this.service.updateProfileSection(id, sectionId, data, user);
92
+ return {
93
+ success: true,
94
+ message: 'Section updated successfully'
95
+ };
96
+ }
97
+ /** Get profile completion percentage */ async getProfileCompletion(id, user) {
98
+ const percentage = await this.service.getProfileCompletion(id, user);
99
+ return {
100
+ success: true,
101
+ data: {
102
+ completionPercentage: percentage
103
+ }
104
+ };
105
+ }
76
106
  constructor(service){
77
107
  super(service), _define_property(this, "service", void 0), this.service = service;
78
108
  }
79
109
  }
110
+ _ts_decorate([
111
+ Post(':id/profile-extras'),
112
+ UseGuards(JwtAuthGuard),
113
+ ApiBearerAuth(),
114
+ ApiOperation({
115
+ summary: 'Get user profile with extras',
116
+ description: 'Returns user profile along with extra data (roles, permissions, etc.) if UserEnricher is provided.'
117
+ }),
118
+ ApiParam({
119
+ name: 'id',
120
+ description: 'User ID'
121
+ }),
122
+ _ts_param(0, Param('id')),
123
+ _ts_param(1, CurrentUser()),
124
+ _ts_metadata("design:type", Function),
125
+ _ts_metadata("design:paramtypes", [
126
+ String,
127
+ typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
128
+ ]),
129
+ _ts_metadata("design:returntype", Promise)
130
+ ], UserController.prototype, "getProfileWithExtras", null);
80
131
  _ts_decorate([
81
132
  Post(':id/verify-email'),
133
+ UseGuards(JwtAuthGuard),
134
+ ApiBearerAuth(),
82
135
  ApiOperation({
83
136
  summary: 'Verify user email'
84
137
  }),
@@ -95,6 +148,8 @@ _ts_decorate([
95
148
  ], UserController.prototype, "verifyEmail", null);
96
149
  _ts_decorate([
97
150
  Post(':id/verify-phone'),
151
+ UseGuards(JwtAuthGuard),
152
+ ApiBearerAuth(),
98
153
  ApiOperation({
99
154
  summary: 'Verify user phone'
100
155
  }),
@@ -111,6 +166,8 @@ _ts_decorate([
111
166
  ], UserController.prototype, "verifyPhone", null);
112
167
  _ts_decorate([
113
168
  Put(':id/status'),
169
+ UseGuards(JwtAuthGuard),
170
+ ApiBearerAuth(),
114
171
  ApiOperation({
115
172
  summary: 'Update user active status',
116
173
  description: 'Updates user active status. When company feature is enabled, updates the status for the current company context.'
@@ -139,6 +196,8 @@ _ts_decorate([
139
196
  ], UserController.prototype, "updateStatus", null);
140
197
  _ts_decorate([
141
198
  Post('profile'),
199
+ UseGuards(JwtAuthGuard),
200
+ ApiBearerAuth(),
142
201
  ApiOperation({
143
202
  summary: 'Update user profile'
144
203
  }),
@@ -154,11 +213,98 @@ _ts_decorate([
154
213
  ]),
155
214
  _ts_metadata("design:returntype", Promise)
156
215
  ], UserController.prototype, "profile", null);
216
+ _ts_decorate([
217
+ Post('profile-sections'),
218
+ UseGuards(JwtAuthGuard),
219
+ ApiBearerAuth(),
220
+ ApiOperation({
221
+ summary: 'Get profile section definitions',
222
+ description: 'Returns available profile sections for multi-step profile (if enricher configured).'
223
+ }),
224
+ _ts_metadata("design:type", Function),
225
+ _ts_metadata("design:paramtypes", []),
226
+ _ts_metadata("design:returntype", Promise)
227
+ ], UserController.prototype, "getProfileSections", null);
228
+ _ts_decorate([
229
+ Post(':id/profile-section/:sectionId'),
230
+ UseGuards(JwtAuthGuard),
231
+ ApiBearerAuth(),
232
+ ApiOperation({
233
+ summary: 'Get profile section data',
234
+ description: 'Returns data for a specific profile section.'
235
+ }),
236
+ ApiParam({
237
+ name: 'id',
238
+ description: 'User ID'
239
+ }),
240
+ ApiParam({
241
+ name: 'sectionId',
242
+ description: 'Section identifier'
243
+ }),
244
+ _ts_param(0, Param('id')),
245
+ _ts_param(1, Param('sectionId')),
246
+ _ts_param(2, CurrentUser()),
247
+ _ts_metadata("design:type", Function),
248
+ _ts_metadata("design:paramtypes", [
249
+ String,
250
+ String,
251
+ typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
252
+ ]),
253
+ _ts_metadata("design:returntype", Promise)
254
+ ], UserController.prototype, "getProfileSectionData", null);
255
+ _ts_decorate([
256
+ Post(':id/profile-section/:sectionId/update'),
257
+ UseGuards(JwtAuthGuard),
258
+ ApiBearerAuth(),
259
+ ApiOperation({
260
+ summary: 'Update profile section',
261
+ description: 'Updates a specific profile section data.'
262
+ }),
263
+ ApiParam({
264
+ name: 'id',
265
+ description: 'User ID'
266
+ }),
267
+ ApiParam({
268
+ name: 'sectionId',
269
+ description: 'Section identifier'
270
+ }),
271
+ _ts_param(0, Param('id')),
272
+ _ts_param(1, Param('sectionId')),
273
+ _ts_param(2, Body()),
274
+ _ts_param(3, CurrentUser()),
275
+ _ts_metadata("design:type", Function),
276
+ _ts_metadata("design:paramtypes", [
277
+ String,
278
+ String,
279
+ typeof Record === "undefined" ? Object : Record,
280
+ typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
281
+ ]),
282
+ _ts_metadata("design:returntype", Promise)
283
+ ], UserController.prototype, "updateProfileSection", null);
284
+ _ts_decorate([
285
+ Post(':id/profile-completion'),
286
+ UseGuards(JwtAuthGuard),
287
+ ApiBearerAuth(),
288
+ ApiOperation({
289
+ summary: 'Get profile completion percentage',
290
+ description: 'Returns overall profile completion percentage.'
291
+ }),
292
+ ApiParam({
293
+ name: 'id',
294
+ description: 'User ID'
295
+ }),
296
+ _ts_param(0, Param('id')),
297
+ _ts_param(1, CurrentUser()),
298
+ _ts_metadata("design:type", Function),
299
+ _ts_metadata("design:paramtypes", [
300
+ String,
301
+ typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
302
+ ]),
303
+ _ts_metadata("design:returntype", Promise)
304
+ ], UserController.prototype, "getProfileCompletion", null);
157
305
  UserController = _ts_decorate([
158
306
  ApiTags('Users'),
159
- ApiBearerAuth(),
160
307
  Controller('administration/users'),
161
- UseGuards(JwtAuthGuard),
162
308
  _ts_param(0, Inject(UserService)),
163
309
  _ts_metadata("design:type", Function),
164
310
  _ts_metadata("design:paramtypes", [
@@ -22,15 +22,8 @@ function _ts_metadata(k, v) {
22
22
  }
23
23
  import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
24
24
  import { IsEmail, IsNotEmpty, IsOptional, IsString, IsUUID, MaxLength, MinLength, ValidateIf } from 'class-validator';
25
- // =============================================================================
26
- // REQUEST DTOs (Following Controller Endpoint Order)
27
- // =============================================================================
28
- // -----------------------------------------------------------------------------
29
- // 1. LOGIN
30
- // -----------------------------------------------------------------------------
31
- /**
32
- * Login Request DTO
33
- */ export class LoginDto {
25
+ // Request DTOs
26
+ /** Login Request DTO */ export class LoginDto {
34
27
  constructor(){
35
28
  _define_property(this, "email", void 0);
36
29
  _define_property(this, "password", void 0);
@@ -55,13 +48,7 @@ _ts_decorate([
55
48
  MinLength(6),
56
49
  _ts_metadata("design:type", String)
57
50
  ], LoginDto.prototype, "password", void 0);
58
- // -----------------------------------------------------------------------------
59
- // 2. REGISTER
60
- // -----------------------------------------------------------------------------
61
- /**
62
- * Registration Request DTO
63
- * Supports both simple registration and company-based registration
64
- */ export class RegistrationDto {
51
+ /** Registration Request DTO - Supports simple and company-based registration */ export class RegistrationDto {
65
52
  constructor(){
66
53
  _define_property(this, "name", void 0);
67
54
  _define_property(this, "email", void 0);
@@ -166,13 +153,7 @@ _ts_decorate([
166
153
  IsString(),
167
154
  _ts_metadata("design:type", String)
168
155
  ], RegistrationDto.prototype, "newCompanyAddress", void 0);
169
- // -----------------------------------------------------------------------------
170
- // 3. REFRESH TOKEN
171
- // -----------------------------------------------------------------------------
172
- /**
173
- * Refresh Token Request DTO
174
- * Note: refreshToken is optional in body - browsers send it via HTTP-only cookie
175
- */ export class RefreshTokenDto {
156
+ /** Refresh Token Request DTO - refreshToken optional in body (browsers use HTTP-only cookie) */ export class RefreshTokenDto {
176
157
  constructor(){
177
158
  _define_property(this, "refreshToken", void 0);
178
159
  }
@@ -186,12 +167,7 @@ _ts_decorate([
186
167
  IsString(),
187
168
  _ts_metadata("design:type", String)
188
169
  ], RefreshTokenDto.prototype, "refreshToken", void 0);
189
- // -----------------------------------------------------------------------------
190
- // 4. CHANGE PASSWORD
191
- // -----------------------------------------------------------------------------
192
- /**
193
- * Change Password Request DTO
194
- */ export class ChangePasswordDto {
170
+ /** Change Password Request DTO */ export class ChangePasswordDto {
195
171
  constructor(){
196
172
  _define_property(this, "currentPassword", void 0);
197
173
  _define_property(this, "newPassword", void 0);
@@ -216,14 +192,7 @@ _ts_decorate([
216
192
  MinLength(6),
217
193
  _ts_metadata("design:type", String)
218
194
  ], ChangePasswordDto.prototype, "newPassword", void 0);
219
- // -----------------------------------------------------------------------------
220
- // 5. SELECT COMPANY & BRANCH (Step 2 - after login with multiple options)
221
- // -----------------------------------------------------------------------------
222
- /**
223
- * Select Company & Branch Request DTO
224
- * Used after login when user needs to select company and branch
225
- * Frontend receives all companies with their branches, user selects both
226
- */ export class SelectDto {
195
+ /** Select Company & Branch Request DTO - Used after login when user needs to select company and branch */ export class SelectDto {
227
196
  constructor(){
228
197
  _define_property(this, "sessionId", void 0);
229
198
  _define_property(this, "companyId", void 0);
@@ -257,13 +226,7 @@ _ts_decorate([
257
226
  IsNotEmpty(),
258
227
  _ts_metadata("design:type", String)
259
228
  ], SelectDto.prototype, "branchId", void 0);
260
- // -----------------------------------------------------------------------------
261
- // 7. SWITCH COMPANY/BRANCH (after already logged in)
262
- // -----------------------------------------------------------------------------
263
- /**
264
- * Switch Company Request DTO
265
- * Used to switch company/branch after login
266
- */ export class SwitchCompanyDto {
229
+ /** Switch Company Request DTO - Used to switch company/branch after login */ export class SwitchCompanyDto {
267
230
  constructor(){
268
231
  _define_property(this, "companyId", void 0);
269
232
  _define_property(this, "branchId", void 0);
@@ -287,15 +250,8 @@ _ts_decorate([
287
250
  IsNotEmpty(),
288
251
  _ts_metadata("design:type", String)
289
252
  ], SwitchCompanyDto.prototype, "branchId", void 0);
290
- // =============================================================================
291
- // RESPONSE DTOs
292
- // =============================================================================
293
- // -----------------------------------------------------------------------------
294
- // NESTED/HELPER DTOs (Used in Response DTOs)
295
- // -----------------------------------------------------------------------------
296
- /**
297
- * User Info DTO (used in responses)
298
- */ export class UserInfoDto {
253
+ // Response DTOs
254
+ /** User Info DTO (used in responses) */ export class UserInfoDto {
299
255
  constructor(){
300
256
  _define_property(this, "id", void 0);
301
257
  _define_property(this, "email", void 0);
@@ -329,9 +285,7 @@ _ts_decorate([
329
285
  }),
330
286
  _ts_metadata("design:type", Object)
331
287
  ], UserInfoDto.prototype, "profilePictureId", void 0);
332
- /**
333
- * Company Info DTO (used in responses)
334
- */ export class CompanyInfoDto {
288
+ /** Company Info DTO (used in responses) */ export class CompanyInfoDto {
335
289
  constructor(){
336
290
  _define_property(this, "id", void 0);
337
291
  _define_property(this, "name", void 0);
@@ -365,9 +319,7 @@ _ts_decorate([
365
319
  }),
366
320
  _ts_metadata("design:type", Object)
367
321
  ], CompanyInfoDto.prototype, "logoId", void 0);
368
- /**
369
- * Branch Info DTO (used in responses)
370
- */ export class BranchInfoDto {
322
+ /** Branch Info DTO (used in responses) */ export class BranchInfoDto {
371
323
  constructor(){
372
324
  _define_property(this, "id", void 0);
373
325
  _define_property(this, "name", void 0);
@@ -401,9 +353,7 @@ _ts_decorate([
401
353
  }),
402
354
  _ts_metadata("design:type", Object)
403
355
  ], BranchInfoDto.prototype, "logoId", void 0);
404
- /**
405
- * Branch Info for Selection (with additional fields)
406
- */ export class BranchSelectionInfoDto {
356
+ /** Branch Info for Selection (with additional fields) */ export class BranchSelectionInfoDto {
407
357
  constructor(){
408
358
  _define_property(this, "id", void 0);
409
359
  _define_property(this, "name", void 0);
@@ -444,9 +394,7 @@ _ts_decorate([
444
394
  }),
445
395
  _ts_metadata("design:type", Object)
446
396
  ], BranchSelectionInfoDto.prototype, "logoId", void 0);
447
- /**
448
- * Company with Branches DTO (for selection response)
449
- */ export class CompanyWithBranchesDto {
397
+ /** Company with Branches DTO (for selection response) */ export class CompanyWithBranchesDto {
450
398
  constructor(){
451
399
  _define_property(this, "id", void 0);
452
400
  _define_property(this, "name", void 0);
@@ -497,13 +445,7 @@ _ts_decorate([
497
445
  }),
498
446
  _ts_metadata("design:type", Array)
499
447
  ], CompanyWithBranchesDto.prototype, "branches", void 0);
500
- // -----------------------------------------------------------------------------
501
- // LOGIN RESPONSE
502
- // -----------------------------------------------------------------------------
503
- /**
504
- * Login Response DTO
505
- * Returned on successful login with tokens
506
- */ export class LoginResponseDto {
448
+ /** Login Response DTO - Returned on successful login with tokens */ export class LoginResponseDto {
507
449
  constructor(){
508
450
  _define_property(this, "accessToken", void 0);
509
451
  _define_property(this, "refreshToken", void 0);
@@ -553,13 +495,7 @@ _ts_decorate([
553
495
  }),
554
496
  _ts_metadata("design:type", Boolean)
555
497
  ], LoginResponseDto.prototype, "companyFeatureEnabled", void 0);
556
- // -----------------------------------------------------------------------------
557
- // REGISTRATION RESPONSE
558
- // -----------------------------------------------------------------------------
559
- /**
560
- * Registration Response DTO
561
- * Returned on successful registration
562
- */ export class RegistrationResponseDto {
498
+ /** Registration Response DTO - Returned on successful registration */ export class RegistrationResponseDto {
563
499
  constructor(){
564
500
  _define_property(this, "accessToken", void 0);
565
501
  _define_property(this, "refreshToken", void 0);
@@ -567,16 +503,17 @@ _ts_decorate([
567
503
  _define_property(this, "company", void 0);
568
504
  _define_property(this, "branch", void 0);
569
505
  _define_property(this, "companyFeatureEnabled", void 0);
506
+ _define_property(this, "requiresEmailVerification", void 0);
570
507
  }
571
508
  }
572
509
  _ts_decorate([
573
- ApiProperty({
510
+ ApiPropertyOptional({
574
511
  example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
575
512
  }),
576
513
  _ts_metadata("design:type", String)
577
514
  ], RegistrationResponseDto.prototype, "accessToken", void 0);
578
515
  _ts_decorate([
579
- ApiProperty({
516
+ ApiPropertyOptional({
580
517
  example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
581
518
  }),
582
519
  _ts_metadata("design:type", String)
@@ -603,22 +540,20 @@ _ts_decorate([
603
540
  _ts_metadata("design:type", typeof BranchInfoDto === "undefined" ? Object : BranchInfoDto)
604
541
  ], RegistrationResponseDto.prototype, "branch", void 0);
605
542
  _ts_decorate([
606
- ApiProperty({
543
+ ApiPropertyOptional({
607
544
  example: true,
608
545
  description: 'Whether company feature is enabled'
609
546
  }),
610
547
  _ts_metadata("design:type", Boolean)
611
548
  ], RegistrationResponseDto.prototype, "companyFeatureEnabled", void 0);
612
- // -----------------------------------------------------------------------------
613
- // ME (GET CURRENT USER INFO) RESPONSE
614
- // -----------------------------------------------------------------------------
615
- /**
616
- * Me Response DTO
617
- * Returned by GET /auth/me endpoint
618
- * Does NOT include accessToken or refreshToken - only user data
619
- * Company and branch are optional - only present when company feature is enabled
620
- * These fields are automatically hidden in Swagger when company feature is disabled
621
- */ export class MeResponseDto {
549
+ _ts_decorate([
550
+ ApiPropertyOptional({
551
+ example: true,
552
+ description: 'Whether email verification is required'
553
+ }),
554
+ _ts_metadata("design:type", Boolean)
555
+ ], RegistrationResponseDto.prototype, "requiresEmailVerification", void 0);
556
+ /** Me Response DTO - Returned by GET /auth/me (user data only, no tokens) */ export class MeResponseDto {
622
557
  constructor(){
623
558
  _define_property(this, "user", void 0);
624
559
  _define_property(this, "company", void 0);
@@ -646,14 +581,7 @@ _ts_decorate([
646
581
  }),
647
582
  _ts_metadata("design:type", typeof BranchInfoDto === "undefined" ? Object : BranchInfoDto)
648
583
  ], MeResponseDto.prototype, "branch", void 0);
649
- // -----------------------------------------------------------------------------
650
- // COMPANY/BRANCH SELECTION RESPONSE
651
- // -----------------------------------------------------------------------------
652
- /**
653
- * Company Selection Response DTO
654
- * Returned when user has multiple companies/branches to choose from
655
- * Frontend displays selection UI and calls /select with chosen company + branch
656
- */ export class CompanySelectionResponseDto {
584
+ /** Company Selection Response DTO - Returned when user has multiple companies/branches to choose from */ export class CompanySelectionResponseDto {
657
585
  constructor(){
658
586
  _define_property(this, "requiresSelection", void 0);
659
587
  _define_property(this, "sessionId", void 0);
@@ -699,3 +627,84 @@ _ts_decorate([
699
627
  }),
700
628
  _ts_metadata("design:type", Array)
701
629
  ], CompanySelectionResponseDto.prototype, "companies", void 0);
630
+ /** Login Response when email verification required */ export class LoginResponseRequiresEmailVerificationDto {
631
+ constructor(){
632
+ _define_property(this, "requiresEmailVerification", void 0);
633
+ _define_property(this, "email", void 0);
634
+ _define_property(this, "message", void 0);
635
+ }
636
+ }
637
+ _ts_decorate([
638
+ ApiProperty({
639
+ example: true
640
+ }),
641
+ _ts_metadata("design:type", Boolean)
642
+ ], LoginResponseRequiresEmailVerificationDto.prototype, "requiresEmailVerification", void 0);
643
+ _ts_decorate([
644
+ ApiProperty({
645
+ example: 'john@example.com'
646
+ }),
647
+ _ts_metadata("design:type", String)
648
+ ], LoginResponseRequiresEmailVerificationDto.prototype, "email", void 0);
649
+ _ts_decorate([
650
+ ApiProperty({
651
+ example: 'Please verify your email address before logging in.'
652
+ }),
653
+ _ts_metadata("design:type", String)
654
+ ], LoginResponseRequiresEmailVerificationDto.prototype, "message", void 0);
655
+ // Email Auth DTOs
656
+ /** Forgot Password Request DTO - Initiates password reset flow */ export class ForgotPasswordDto {
657
+ constructor(){
658
+ _define_property(this, "email", void 0);
659
+ }
660
+ }
661
+ _ts_decorate([
662
+ ApiProperty({
663
+ example: 'john@example.com',
664
+ description: 'Email address to send reset link to'
665
+ }),
666
+ IsEmail(),
667
+ IsNotEmpty(),
668
+ _ts_metadata("design:type", String)
669
+ ], ForgotPasswordDto.prototype, "email", void 0);
670
+ /** Reset Password Request DTO - Resets password using token */ export class ResetPasswordDto {
671
+ constructor(){
672
+ _define_property(this, "token", void 0);
673
+ _define_property(this, "newPassword", void 0);
674
+ }
675
+ }
676
+ _ts_decorate([
677
+ ApiProperty({
678
+ example: 'a1b2c3d4e5f6...',
679
+ description: 'Password reset token from email'
680
+ }),
681
+ IsString(),
682
+ IsNotEmpty(),
683
+ _ts_metadata("design:type", String)
684
+ ], ResetPasswordDto.prototype, "token", void 0);
685
+ _ts_decorate([
686
+ ApiProperty({
687
+ example: 'newSecurePassword123',
688
+ description: 'New password (min 6 chars)'
689
+ }),
690
+ IsString(),
691
+ IsNotEmpty(),
692
+ MinLength(6),
693
+ _ts_metadata("design:type", String)
694
+ ], ResetPasswordDto.prototype, "newPassword", void 0);
695
+ /** Verify Email Request DTO - Verifies email using token */ export class VerifyEmailDto {
696
+ constructor(){
697
+ _define_property(this, "token", void 0);
698
+ }
699
+ }
700
+ _ts_decorate([
701
+ ApiProperty({
702
+ example: 'a1b2c3d4e5f6...',
703
+ description: 'Email verification token from email'
704
+ }),
705
+ IsString(),
706
+ IsNotEmpty(),
707
+ _ts_metadata("design:type", String)
708
+ ], VerifyEmailDto.prototype, "token", void 0);
709
+ /** Resend Verification Email Request DTO - Same structure as ForgotPasswordDto */ export class ResendVerificationDto extends ForgotPasswordDto {
710
+ }
@@ -1,13 +1,19 @@
1
1
  export * from './company-branch.entity';
2
2
  export * from './company.entity';
3
+ export * from './pending-registration.entity';
3
4
  export { PermissionType, UserCompanyPermission } from './user-company-permission.entity';
4
5
  export * from './user.entity';
6
+ export * from './user-token.entity';
5
7
  import { CompanyBranch } from './company-branch.entity';
6
8
  import { Company } from './company.entity';
9
+ import { PendingRegistration } from './pending-registration.entity';
7
10
  import { UserCompanyPermission } from './user-company-permission.entity';
8
11
  import { User } from './user.entity';
12
+ import { UserToken } from './user-token.entity';
9
13
  export const CoreEntities = [
10
- User
14
+ User,
15
+ UserToken,
16
+ PendingRegistration
11
17
  ];
12
18
  export const CompanyEntities = [
13
19
  Company,