@flusys/nestjs-auth 1.0.0-beta → 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.
- package/cjs/config/auth.constants.js +4 -0
- package/cjs/controllers/authentication.controller.js +167 -5
- package/cjs/controllers/user.controller.js +151 -0
- package/cjs/dtos/authentication.dto.js +106 -3
- package/cjs/entities/index.js +5 -1
- package/cjs/entities/pending-registration.entity.js +125 -0
- package/cjs/entities/user-token.entity.js +129 -0
- 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 -2
- package/cjs/services/auth-config.service.js +4 -0
- package/cjs/services/auth-datasource.provider.js +4 -2
- package/cjs/services/auth-email.service.js +452 -0
- package/cjs/services/authentication.service.js +156 -37
- package/cjs/services/index.js +1 -0
- package/cjs/services/user.service.js +147 -11
- package/config/auth.constants.d.ts +1 -0
- package/controllers/authentication.controller.d.ts +13 -9
- package/controllers/user.controller.d.ts +27 -0
- package/dtos/authentication.dto.d.ts +21 -3
- package/dtos/user.dto.d.ts +1 -0
- package/entities/index.d.ts +7 -3
- package/entities/pending-registration.entity.d.ts +17 -0
- package/entities/user-token.entity.d.ts +15 -0
- package/fesm/config/auth.constants.js +11 -0
- package/fesm/controllers/authentication.controller.js +168 -6
- package/fesm/controllers/user.controller.js +151 -0
- package/fesm/dtos/authentication.dto.js +92 -3
- package/fesm/entities/index.js +7 -1
- package/fesm/entities/pending-registration.entity.js +115 -0
- package/fesm/entities/user-token.entity.js +113 -0
- 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 +9 -3
- package/fesm/services/auth-config.service.js +4 -0
- package/fesm/services/auth-datasource.provider.js +4 -2
- package/fesm/services/auth-email.service.js +401 -0
- package/fesm/services/authentication.service.js +156 -37
- package/fesm/services/index.js +1 -0
- package/fesm/services/user.service.js +149 -13
- 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 +67 -0
- package/interfaces/user.interface.d.ts +1 -0
- package/package.json +3 -3
- package/services/auth-config.service.d.ts +1 -0
- package/services/auth-email.service.d.ts +50 -0
- package/services/authentication.service.d.ts +16 -4
- package/services/index.d.ts +1 -0
- package/services/user.service.d.ts +16 -3
|
@@ -21,9 +21,13 @@ _export(exports, {
|
|
|
21
21
|
},
|
|
22
22
|
get TOKEN_REVOKED_PREFIX () {
|
|
23
23
|
return TOKEN_REVOKED_PREFIX;
|
|
24
|
+
},
|
|
25
|
+
get USER_ENRICHER () {
|
|
26
|
+
return USER_ENRICHER;
|
|
24
27
|
}
|
|
25
28
|
});
|
|
26
29
|
const AUTH_MODULE_OPTIONS = 'AUTH_MODULE_OPTIONS';
|
|
30
|
+
const USER_ENRICHER = 'USER_ENRICHER';
|
|
27
31
|
const BCRYPT_SALT_ROUNDS = 12;
|
|
28
32
|
const SESSION_CACHE_PREFIX = 'auth:session';
|
|
29
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,6 +49,10 @@ function _ts_param(paramIndex, decorator) {
|
|
|
47
49
|
};
|
|
48
50
|
}
|
|
49
51
|
let AuthenticationController = class AuthenticationController {
|
|
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
|
+
}
|
|
50
56
|
// Core Endpoints
|
|
51
57
|
/** Login - Returns tokens or company/branch selection requirement */ async login(loginDto) {
|
|
52
58
|
const result = await this.authService.login(loginDto.email, loginDto.password);
|
|
@@ -55,8 +61,9 @@ let AuthenticationController = class AuthenticationController {
|
|
|
55
61
|
}
|
|
56
62
|
return result;
|
|
57
63
|
}
|
|
58
|
-
/** Register new user. If company feature enabled, can join/create company. */ async register(registrationDto) {
|
|
59
|
-
const
|
|
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);
|
|
60
67
|
return {
|
|
61
68
|
...result,
|
|
62
69
|
companyFeatureEnabled: this.authConfig?.isCompanyFeatureEnabled() ?? false
|
|
@@ -77,21 +84,74 @@ let AuthenticationController = class AuthenticationController {
|
|
|
77
84
|
/** Logout - Clears refresh token cookie for browsers */ async logout(userId) {
|
|
78
85
|
await this.authService.logout(userId);
|
|
79
86
|
return {
|
|
87
|
+
success: true,
|
|
80
88
|
message: 'Logged out successfully'
|
|
81
89
|
};
|
|
82
90
|
}
|
|
83
91
|
/** Change password */ async changePassword(userId, dto) {
|
|
84
92
|
await this.authService.changePassword(userId, dto.currentPassword, dto.newPassword);
|
|
85
93
|
return {
|
|
94
|
+
success: true,
|
|
86
95
|
message: 'Password changed successfully'
|
|
87
96
|
};
|
|
88
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
|
+
}
|
|
89
147
|
// NOTE: @Inject() required for bundled code - type metadata may be lost during esbuild
|
|
90
|
-
constructor(authService, authConfig){
|
|
148
|
+
constructor(authService, authConfig, authEmailService){
|
|
91
149
|
_define_property(this, "authService", void 0);
|
|
92
150
|
_define_property(this, "authConfig", void 0);
|
|
151
|
+
_define_property(this, "authEmailService", void 0);
|
|
93
152
|
this.authService = authService;
|
|
94
153
|
this.authConfig = authConfig;
|
|
154
|
+
this.authEmailService = authEmailService;
|
|
95
155
|
}
|
|
96
156
|
};
|
|
97
157
|
_ts_decorate([
|
|
@@ -133,9 +193,11 @@ _ts_decorate([
|
|
|
133
193
|
status: 201,
|
|
134
194
|
type: _authenticationdto.RegistrationResponseDto
|
|
135
195
|
}),
|
|
136
|
-
_ts_param(0, (0, _common.
|
|
196
|
+
_ts_param(0, (0, _common.Req)()),
|
|
197
|
+
_ts_param(1, (0, _common.Body)()),
|
|
137
198
|
_ts_metadata("design:type", Function),
|
|
138
199
|
_ts_metadata("design:paramtypes", [
|
|
200
|
+
typeof _express.Request === "undefined" ? Object : _express.Request,
|
|
139
201
|
typeof _authenticationdto.RegistrationDto === "undefined" ? Object : _authenticationdto.RegistrationDto
|
|
140
202
|
]),
|
|
141
203
|
_ts_metadata("design:returntype", Promise)
|
|
@@ -185,6 +247,10 @@ _ts_decorate([
|
|
|
185
247
|
(0, _swagger.ApiOperation)({
|
|
186
248
|
summary: 'Logout user'
|
|
187
249
|
}),
|
|
250
|
+
(0, _swagger.ApiResponse)({
|
|
251
|
+
status: 200,
|
|
252
|
+
type: _dtos.MessageResponseDto
|
|
253
|
+
}),
|
|
188
254
|
_ts_param(0, (0, _decorators.CurrentUser)('id')),
|
|
189
255
|
_ts_metadata("design:type", Function),
|
|
190
256
|
_ts_metadata("design:paramtypes", [
|
|
@@ -203,6 +269,10 @@ _ts_decorate([
|
|
|
203
269
|
(0, _swagger.ApiBody)({
|
|
204
270
|
type: _authenticationdto.ChangePasswordDto
|
|
205
271
|
}),
|
|
272
|
+
(0, _swagger.ApiResponse)({
|
|
273
|
+
status: 200,
|
|
274
|
+
type: _dtos.MessageResponseDto
|
|
275
|
+
}),
|
|
206
276
|
_ts_param(0, (0, _decorators.CurrentUser)('id')),
|
|
207
277
|
_ts_param(1, (0, _common.Body)()),
|
|
208
278
|
_ts_metadata("design:type", Function),
|
|
@@ -212,15 +282,107 @@ _ts_decorate([
|
|
|
212
282
|
]),
|
|
213
283
|
_ts_metadata("design:returntype", Promise)
|
|
214
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);
|
|
215
374
|
AuthenticationController = _ts_decorate([
|
|
216
375
|
(0, _swagger.ApiTags)('Authentication'),
|
|
217
376
|
(0, _common.Controller)('auth'),
|
|
218
377
|
_ts_param(0, (0, _common.Inject)(_authenticationservice.AuthenticationService)),
|
|
219
378
|
_ts_param(1, (0, _common.Optional)()),
|
|
220
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)),
|
|
221
382
|
_ts_metadata("design:type", Function),
|
|
222
383
|
_ts_metadata("design:paramtypes", [
|
|
223
384
|
typeof _authenticationservice.AuthenticationService === "undefined" ? Object : _authenticationservice.AuthenticationService,
|
|
224
|
-
typeof _authconfigservice.AuthConfigService === "undefined" ? Object : _authconfigservice.AuthConfigService
|
|
385
|
+
typeof _authconfigservice.AuthConfigService === "undefined" ? Object : _authconfigservice.AuthConfigService,
|
|
386
|
+
typeof _authemailservice.AuthEmailService === "undefined" ? Object : _authemailservice.AuthEmailService
|
|
225
387
|
])
|
|
226
388
|
], AuthenticationController);
|
|
@@ -47,6 +47,13 @@ let UserController = class UserController extends (0, _classes.createApiControll
|
|
|
47
47
|
security: 'jwt'
|
|
48
48
|
}) {
|
|
49
49
|
// Custom Endpoints
|
|
50
|
+
/** Get user profile with extras (roles, permissions, etc.) from enricher */ async getProfileWithExtras(id, user) {
|
|
51
|
+
const data = await this.service.getProfileWithExtras(id, user);
|
|
52
|
+
return {
|
|
53
|
+
success: true,
|
|
54
|
+
data
|
|
55
|
+
};
|
|
56
|
+
}
|
|
50
57
|
/** Verify user email */ async verifyEmail(id) {
|
|
51
58
|
await this.service.verifyEmail(id);
|
|
52
59
|
return {
|
|
@@ -68,14 +75,69 @@ let UserController = class UserController extends (0, _classes.createApiControll
|
|
|
68
75
|
/** Update user profile */ async profile(dto, user) {
|
|
69
76
|
const data = await this.service.profile(dto, user);
|
|
70
77
|
return {
|
|
78
|
+
success: true,
|
|
71
79
|
message: 'Profile updated successfully',
|
|
72
80
|
data
|
|
73
81
|
};
|
|
74
82
|
}
|
|
83
|
+
// ============================================
|
|
84
|
+
// Multi-Step Profile Endpoints (via Enricher)
|
|
85
|
+
// ============================================
|
|
86
|
+
/** Get profile section definitions */ async getProfileSections() {
|
|
87
|
+
const sections = await this.service.getProfileSections();
|
|
88
|
+
return {
|
|
89
|
+
success: true,
|
|
90
|
+
data: sections
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** Get specific profile section data */ async getProfileSectionData(id, sectionId, user) {
|
|
94
|
+
const data = await this.service.getProfileSectionData(id, sectionId, user);
|
|
95
|
+
return {
|
|
96
|
+
success: true,
|
|
97
|
+
data
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/** Update specific profile section */ async updateProfileSection(id, sectionId, data, user) {
|
|
101
|
+
await this.service.updateProfileSection(id, sectionId, data, user);
|
|
102
|
+
return {
|
|
103
|
+
success: true,
|
|
104
|
+
message: 'Section updated successfully'
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/** Get profile completion percentage */ async getProfileCompletion(id, user) {
|
|
108
|
+
const percentage = await this.service.getProfileCompletion(id, user);
|
|
109
|
+
return {
|
|
110
|
+
success: true,
|
|
111
|
+
data: {
|
|
112
|
+
completionPercentage: percentage
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
75
116
|
constructor(service){
|
|
76
117
|
super(service), _define_property(this, "service", void 0), this.service = service;
|
|
77
118
|
}
|
|
78
119
|
};
|
|
120
|
+
_ts_decorate([
|
|
121
|
+
(0, _common.Post)(':id/profile-extras'),
|
|
122
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
123
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
124
|
+
(0, _swagger.ApiOperation)({
|
|
125
|
+
summary: 'Get user profile with extras',
|
|
126
|
+
description: 'Returns user profile along with extra data (roles, permissions, etc.) if UserEnricher is provided.'
|
|
127
|
+
}),
|
|
128
|
+
(0, _swagger.ApiParam)({
|
|
129
|
+
name: 'id',
|
|
130
|
+
description: 'User ID'
|
|
131
|
+
}),
|
|
132
|
+
_ts_param(0, (0, _common.Param)('id')),
|
|
133
|
+
_ts_param(1, (0, _decorators.CurrentUser)()),
|
|
134
|
+
_ts_metadata("design:type", Function),
|
|
135
|
+
_ts_metadata("design:paramtypes", [
|
|
136
|
+
String,
|
|
137
|
+
typeof _interfaces.ILoggedUserInfo === "undefined" ? Object : _interfaces.ILoggedUserInfo
|
|
138
|
+
]),
|
|
139
|
+
_ts_metadata("design:returntype", Promise)
|
|
140
|
+
], UserController.prototype, "getProfileWithExtras", null);
|
|
79
141
|
_ts_decorate([
|
|
80
142
|
(0, _common.Post)(':id/verify-email'),
|
|
81
143
|
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
@@ -161,6 +223,95 @@ _ts_decorate([
|
|
|
161
223
|
]),
|
|
162
224
|
_ts_metadata("design:returntype", Promise)
|
|
163
225
|
], UserController.prototype, "profile", null);
|
|
226
|
+
_ts_decorate([
|
|
227
|
+
(0, _common.Post)('profile-sections'),
|
|
228
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
229
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
230
|
+
(0, _swagger.ApiOperation)({
|
|
231
|
+
summary: 'Get profile section definitions',
|
|
232
|
+
description: 'Returns available profile sections for multi-step profile (if enricher configured).'
|
|
233
|
+
}),
|
|
234
|
+
_ts_metadata("design:type", Function),
|
|
235
|
+
_ts_metadata("design:paramtypes", []),
|
|
236
|
+
_ts_metadata("design:returntype", Promise)
|
|
237
|
+
], UserController.prototype, "getProfileSections", null);
|
|
238
|
+
_ts_decorate([
|
|
239
|
+
(0, _common.Post)(':id/profile-section/:sectionId'),
|
|
240
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
241
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
242
|
+
(0, _swagger.ApiOperation)({
|
|
243
|
+
summary: 'Get profile section data',
|
|
244
|
+
description: 'Returns data for a specific profile section.'
|
|
245
|
+
}),
|
|
246
|
+
(0, _swagger.ApiParam)({
|
|
247
|
+
name: 'id',
|
|
248
|
+
description: 'User ID'
|
|
249
|
+
}),
|
|
250
|
+
(0, _swagger.ApiParam)({
|
|
251
|
+
name: 'sectionId',
|
|
252
|
+
description: 'Section identifier'
|
|
253
|
+
}),
|
|
254
|
+
_ts_param(0, (0, _common.Param)('id')),
|
|
255
|
+
_ts_param(1, (0, _common.Param)('sectionId')),
|
|
256
|
+
_ts_param(2, (0, _decorators.CurrentUser)()),
|
|
257
|
+
_ts_metadata("design:type", Function),
|
|
258
|
+
_ts_metadata("design:paramtypes", [
|
|
259
|
+
String,
|
|
260
|
+
String,
|
|
261
|
+
typeof _interfaces.ILoggedUserInfo === "undefined" ? Object : _interfaces.ILoggedUserInfo
|
|
262
|
+
]),
|
|
263
|
+
_ts_metadata("design:returntype", Promise)
|
|
264
|
+
], UserController.prototype, "getProfileSectionData", null);
|
|
265
|
+
_ts_decorate([
|
|
266
|
+
(0, _common.Post)(':id/profile-section/:sectionId/update'),
|
|
267
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
268
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
269
|
+
(0, _swagger.ApiOperation)({
|
|
270
|
+
summary: 'Update profile section',
|
|
271
|
+
description: 'Updates a specific profile section data.'
|
|
272
|
+
}),
|
|
273
|
+
(0, _swagger.ApiParam)({
|
|
274
|
+
name: 'id',
|
|
275
|
+
description: 'User ID'
|
|
276
|
+
}),
|
|
277
|
+
(0, _swagger.ApiParam)({
|
|
278
|
+
name: 'sectionId',
|
|
279
|
+
description: 'Section identifier'
|
|
280
|
+
}),
|
|
281
|
+
_ts_param(0, (0, _common.Param)('id')),
|
|
282
|
+
_ts_param(1, (0, _common.Param)('sectionId')),
|
|
283
|
+
_ts_param(2, (0, _common.Body)()),
|
|
284
|
+
_ts_param(3, (0, _decorators.CurrentUser)()),
|
|
285
|
+
_ts_metadata("design:type", Function),
|
|
286
|
+
_ts_metadata("design:paramtypes", [
|
|
287
|
+
String,
|
|
288
|
+
String,
|
|
289
|
+
typeof Record === "undefined" ? Object : Record,
|
|
290
|
+
typeof _interfaces.ILoggedUserInfo === "undefined" ? Object : _interfaces.ILoggedUserInfo
|
|
291
|
+
]),
|
|
292
|
+
_ts_metadata("design:returntype", Promise)
|
|
293
|
+
], UserController.prototype, "updateProfileSection", null);
|
|
294
|
+
_ts_decorate([
|
|
295
|
+
(0, _common.Post)(':id/profile-completion'),
|
|
296
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
297
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
298
|
+
(0, _swagger.ApiOperation)({
|
|
299
|
+
summary: 'Get profile completion percentage',
|
|
300
|
+
description: 'Returns overall profile completion percentage.'
|
|
301
|
+
}),
|
|
302
|
+
(0, _swagger.ApiParam)({
|
|
303
|
+
name: 'id',
|
|
304
|
+
description: 'User ID'
|
|
305
|
+
}),
|
|
306
|
+
_ts_param(0, (0, _common.Param)('id')),
|
|
307
|
+
_ts_param(1, (0, _decorators.CurrentUser)()),
|
|
308
|
+
_ts_metadata("design:type", Function),
|
|
309
|
+
_ts_metadata("design:paramtypes", [
|
|
310
|
+
String,
|
|
311
|
+
typeof _interfaces.ILoggedUserInfo === "undefined" ? Object : _interfaces.ILoggedUserInfo
|
|
312
|
+
]),
|
|
313
|
+
_ts_metadata("design:returntype", Promise)
|
|
314
|
+
], UserController.prototype, "getProfileCompletion", null);
|
|
164
315
|
UserController = _ts_decorate([
|
|
165
316
|
(0, _swagger.ApiTags)('Users'),
|
|
166
317
|
(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,6 +65,9 @@ _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");
|
|
@@ -558,16 +573,17 @@ let RegistrationResponseDto = class RegistrationResponseDto {
|
|
|
558
573
|
_define_property(this, "company", void 0);
|
|
559
574
|
_define_property(this, "branch", void 0);
|
|
560
575
|
_define_property(this, "companyFeatureEnabled", void 0);
|
|
576
|
+
_define_property(this, "requiresEmailVerification", void 0);
|
|
561
577
|
}
|
|
562
578
|
};
|
|
563
579
|
_ts_decorate([
|
|
564
|
-
(0, _swagger.
|
|
580
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
565
581
|
example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
|
|
566
582
|
}),
|
|
567
583
|
_ts_metadata("design:type", String)
|
|
568
584
|
], RegistrationResponseDto.prototype, "accessToken", void 0);
|
|
569
585
|
_ts_decorate([
|
|
570
|
-
(0, _swagger.
|
|
586
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
571
587
|
example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
|
|
572
588
|
}),
|
|
573
589
|
_ts_metadata("design:type", String)
|
|
@@ -594,12 +610,19 @@ _ts_decorate([
|
|
|
594
610
|
_ts_metadata("design:type", typeof BranchInfoDto === "undefined" ? Object : BranchInfoDto)
|
|
595
611
|
], RegistrationResponseDto.prototype, "branch", void 0);
|
|
596
612
|
_ts_decorate([
|
|
597
|
-
(0, _swagger.
|
|
613
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
598
614
|
example: true,
|
|
599
615
|
description: 'Whether company feature is enabled'
|
|
600
616
|
}),
|
|
601
617
|
_ts_metadata("design:type", Boolean)
|
|
602
618
|
], RegistrationResponseDto.prototype, "companyFeatureEnabled", void 0);
|
|
619
|
+
_ts_decorate([
|
|
620
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
621
|
+
example: true,
|
|
622
|
+
description: 'Whether email verification is required'
|
|
623
|
+
}),
|
|
624
|
+
_ts_metadata("design:type", Boolean)
|
|
625
|
+
], RegistrationResponseDto.prototype, "requiresEmailVerification", void 0);
|
|
603
626
|
let MeResponseDto = class MeResponseDto {
|
|
604
627
|
constructor(){
|
|
605
628
|
_define_property(this, "user", void 0);
|
|
@@ -674,3 +697,83 @@ _ts_decorate([
|
|
|
674
697
|
}),
|
|
675
698
|
_ts_metadata("design:type", Array)
|
|
676
699
|
], CompanySelectionResponseDto.prototype, "companies", void 0);
|
|
700
|
+
let LoginResponseRequiresEmailVerificationDto = class LoginResponseRequiresEmailVerificationDto {
|
|
701
|
+
constructor(){
|
|
702
|
+
_define_property(this, "requiresEmailVerification", void 0);
|
|
703
|
+
_define_property(this, "email", void 0);
|
|
704
|
+
_define_property(this, "message", void 0);
|
|
705
|
+
}
|
|
706
|
+
};
|
|
707
|
+
_ts_decorate([
|
|
708
|
+
(0, _swagger.ApiProperty)({
|
|
709
|
+
example: true
|
|
710
|
+
}),
|
|
711
|
+
_ts_metadata("design:type", Boolean)
|
|
712
|
+
], LoginResponseRequiresEmailVerificationDto.prototype, "requiresEmailVerification", void 0);
|
|
713
|
+
_ts_decorate([
|
|
714
|
+
(0, _swagger.ApiProperty)({
|
|
715
|
+
example: 'john@example.com'
|
|
716
|
+
}),
|
|
717
|
+
_ts_metadata("design:type", String)
|
|
718
|
+
], LoginResponseRequiresEmailVerificationDto.prototype, "email", void 0);
|
|
719
|
+
_ts_decorate([
|
|
720
|
+
(0, _swagger.ApiProperty)({
|
|
721
|
+
example: 'Please verify your email address before logging in.'
|
|
722
|
+
}),
|
|
723
|
+
_ts_metadata("design:type", String)
|
|
724
|
+
], LoginResponseRequiresEmailVerificationDto.prototype, "message", void 0);
|
|
725
|
+
let ForgotPasswordDto = class ForgotPasswordDto {
|
|
726
|
+
constructor(){
|
|
727
|
+
_define_property(this, "email", void 0);
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
_ts_decorate([
|
|
731
|
+
(0, _swagger.ApiProperty)({
|
|
732
|
+
example: 'john@example.com',
|
|
733
|
+
description: 'Email address to send reset link to'
|
|
734
|
+
}),
|
|
735
|
+
(0, _classvalidator.IsEmail)(),
|
|
736
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
737
|
+
_ts_metadata("design:type", String)
|
|
738
|
+
], ForgotPasswordDto.prototype, "email", void 0);
|
|
739
|
+
let ResetPasswordDto = class ResetPasswordDto {
|
|
740
|
+
constructor(){
|
|
741
|
+
_define_property(this, "token", void 0);
|
|
742
|
+
_define_property(this, "newPassword", void 0);
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
_ts_decorate([
|
|
746
|
+
(0, _swagger.ApiProperty)({
|
|
747
|
+
example: 'a1b2c3d4e5f6...',
|
|
748
|
+
description: 'Password reset token from email'
|
|
749
|
+
}),
|
|
750
|
+
(0, _classvalidator.IsString)(),
|
|
751
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
752
|
+
_ts_metadata("design:type", String)
|
|
753
|
+
], ResetPasswordDto.prototype, "token", void 0);
|
|
754
|
+
_ts_decorate([
|
|
755
|
+
(0, _swagger.ApiProperty)({
|
|
756
|
+
example: 'newSecurePassword123',
|
|
757
|
+
description: 'New password (min 6 chars)'
|
|
758
|
+
}),
|
|
759
|
+
(0, _classvalidator.IsString)(),
|
|
760
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
761
|
+
(0, _classvalidator.MinLength)(6),
|
|
762
|
+
_ts_metadata("design:type", String)
|
|
763
|
+
], ResetPasswordDto.prototype, "newPassword", void 0);
|
|
764
|
+
let VerifyEmailDto = class VerifyEmailDto {
|
|
765
|
+
constructor(){
|
|
766
|
+
_define_property(this, "token", void 0);
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
_ts_decorate([
|
|
770
|
+
(0, _swagger.ApiProperty)({
|
|
771
|
+
example: 'a1b2c3d4e5f6...',
|
|
772
|
+
description: 'Email verification token from email'
|
|
773
|
+
}),
|
|
774
|
+
(0, _classvalidator.IsString)(),
|
|
775
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
776
|
+
_ts_metadata("design:type", String)
|
|
777
|
+
], VerifyEmailDto.prototype, "token", void 0);
|
|
778
|
+
let ResendVerificationDto = class ResendVerificationDto extends ForgotPasswordDto {
|
|
779
|
+
};
|
package/cjs/entities/index.js
CHANGED
|
@@ -30,8 +30,10 @@ _export(exports, {
|
|
|
30
30
|
});
|
|
31
31
|
const _companybranchentity = _export_star(require("./company-branch.entity"), exports);
|
|
32
32
|
const _companyentity = _export_star(require("./company.entity"), exports);
|
|
33
|
+
const _pendingregistrationentity = _export_star(require("./pending-registration.entity"), exports);
|
|
33
34
|
const _usercompanypermissionentity = require("./user-company-permission.entity");
|
|
34
35
|
const _userentity = _export_star(require("./user.entity"), exports);
|
|
36
|
+
const _usertokenentity = _export_star(require("./user-token.entity"), exports);
|
|
35
37
|
function _export_star(from, to) {
|
|
36
38
|
Object.keys(from).forEach(function(k) {
|
|
37
39
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -46,7 +48,9 @@ function _export_star(from, to) {
|
|
|
46
48
|
return from;
|
|
47
49
|
}
|
|
48
50
|
const CoreEntities = [
|
|
49
|
-
_userentity.User
|
|
51
|
+
_userentity.User,
|
|
52
|
+
_usertokenentity.UserToken,
|
|
53
|
+
_pendingregistrationentity.PendingRegistration
|
|
50
54
|
];
|
|
51
55
|
const CompanyEntities = [
|
|
52
56
|
_companyentity.Company,
|