@flusys/nestjs-auth 7.1.0 → 8.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.
- package/README.md +1 -1
- package/config/index.d.ts +3 -3
- package/config/message-keys.d.ts +4 -0
- package/controllers/authentication.controller.d.ts +5 -5
- package/controllers/branch.controller.d.ts +2 -2
- package/controllers/company-selection.controller.d.ts +4 -4
- package/controllers/company.controller.d.ts +2 -2
- package/controllers/email-verification.controller.d.ts +6 -6
- package/controllers/index.d.ts +9 -9
- package/controllers/social-auth-config.controller.d.ts +2 -2
- package/controllers/social-auth.controller.d.ts +3 -3
- package/controllers/user-permission.controller.d.ts +7 -4
- package/controllers/user.controller.d.ts +7 -7
- package/docs/auth-swagger.config.d.ts +2 -2
- package/docs/index.d.ts +1 -1
- package/dtos/index.d.ts +6 -6
- package/dtos/social-auth.dto.d.ts +1 -1
- package/dtos/user-permission.dto.d.ts +30 -0
- package/entities/company-branch.entity.d.ts +1 -1
- package/entities/company.entity.d.ts +1 -1
- package/entities/index.d.ts +14 -14
- package/entities/pending-registration.entity.d.ts +1 -1
- package/entities/user-company-permission.entity.d.ts +4 -4
- package/enums/index.d.ts +2 -2
- package/fesm/118.js +1404 -0
- package/fesm/120.js +2265 -0
- package/fesm/24.js +4422 -0
- package/fesm/370.js +1163 -0
- package/fesm/446.js +877 -0
- package/fesm/chunks/117.js +69 -0
- package/fesm/config/index.js +246 -3
- package/fesm/controllers/index.js +27 -9
- package/fesm/docs/index.js +479 -1
- package/fesm/dtos/index.js +135 -6
- package/fesm/entities/index.js +68 -22
- package/fesm/enums/index.js +53 -2
- package/fesm/helpers/index.js +115 -2
- package/fesm/index.js +1455 -13
- package/fesm/interceptors/index.js +510 -2
- package/fesm/interfaces/index.js +75 -8
- package/fesm/modules/index.js +546 -1
- package/fesm/runtime.js +134 -0
- package/fesm/services/index.js +67 -11
- package/helpers/auth-response.mapper.d.ts +3 -3
- package/helpers/index.d.ts +2 -2
- package/helpers/token.helper.d.ts +2 -2
- package/index.d.ts +13 -13
- package/interceptors/clear-token.interceptor.d.ts +2 -2
- package/interceptors/index.d.ts +2 -2
- package/interceptors/set-token.interceptor.d.ts +2 -2
- package/interfaces/auth-module-options.interface.d.ts +3 -3
- package/interfaces/authentication.interface.d.ts +3 -3
- package/interfaces/company-branch.interface.d.ts +2 -2
- package/interfaces/company.interface.d.ts +1 -1
- package/interfaces/index.d.ts +8 -8
- package/interfaces/social-auth.interface.d.ts +2 -2
- package/interfaces/user-enricher.interface.d.ts +3 -3
- package/modules/auth.module.d.ts +4 -4
- package/modules/index.d.ts +1 -1
- package/package.json +32 -39
- package/providers/facebook.social-provider.d.ts +2 -2
- package/providers/google.social-provider.d.ts +2 -2
- package/providers/index.d.ts +1 -1
- package/providers/linkedin.social-provider.d.ts +2 -2
- package/providers/microsoft.social-provider.d.ts +2 -2
- package/providers/social-provider.registry.d.ts +2 -2
- package/services/auth-config.service.d.ts +3 -3
- package/services/auth-datasource.provider.d.ts +3 -3
- package/services/auth-email.service.d.ts +3 -3
- package/services/authentication.service.d.ts +12 -12
- package/services/branch.service.d.ts +7 -7
- package/services/company.service.d.ts +6 -6
- package/services/index.d.ts +11 -11
- package/services/social-auth-config.service.d.ts +6 -6
- package/services/social-auth.service.d.ts +5 -5
- package/services/user-permission.service.d.ts +10 -4
- package/services/user.service.d.ts +7 -7
- package/strategies/jwt.strategy.d.ts +4 -4
- package/validators/password.validator.d.ts +1 -1
- package/cjs/config/auth.constants.js +0 -49
- package/cjs/config/event-actions.js +0 -47
- package/cjs/config/index.js +0 -20
- package/cjs/config/message-keys.js +0 -135
- package/cjs/controllers/authentication.controller.js +0 -427
- package/cjs/controllers/authentication.controller.spec.js +0 -219
- package/cjs/controllers/branch.controller.js +0 -102
- package/cjs/controllers/branch.controller.spec.js +0 -134
- package/cjs/controllers/company-selection.controller.js +0 -198
- package/cjs/controllers/company-selection.controller.spec.js +0 -84
- package/cjs/controllers/company.controller.js +0 -102
- package/cjs/controllers/company.controller.spec.js +0 -131
- package/cjs/controllers/email-verification.controller.js +0 -224
- package/cjs/controllers/email-verification.controller.spec.js +0 -142
- package/cjs/controllers/index.js +0 -26
- package/cjs/controllers/social-auth-config.controller.js +0 -107
- package/cjs/controllers/social-auth.controller.js +0 -175
- package/cjs/controllers/social-auth.controller.spec.js +0 -79
- package/cjs/controllers/user-permission.controller.js +0 -223
- package/cjs/controllers/user-permission.controller.spec.js +0 -138
- package/cjs/controllers/user.controller.js +0 -438
- package/cjs/controllers/user.controller.spec.js +0 -204
- package/cjs/docs/auth-swagger.config.js +0 -461
- package/cjs/docs/auth-swagger.config.spec.js +0 -130
- package/cjs/docs/index.js +0 -18
- package/cjs/dtos/authentication.dto.js +0 -755
- package/cjs/dtos/company-branch.dto.js +0 -294
- package/cjs/dtos/company.dto.js +0 -298
- package/cjs/dtos/index.js +0 -23
- package/cjs/dtos/social-auth.dto.js +0 -318
- package/cjs/dtos/user-permission.dto.js +0 -358
- package/cjs/dtos/user.dto.js +0 -413
- package/cjs/entities/app-user.entity.js +0 -25
- package/cjs/entities/company-branch.entity.js +0 -163
- package/cjs/entities/company.entity.js +0 -146
- package/cjs/entities/index.js +0 -67
- package/cjs/entities/index.spec.js +0 -84
- package/cjs/entities/pending-registration.entity.js +0 -135
- package/cjs/entities/social-auth-config.entity.js +0 -102
- package/cjs/entities/user-company-permission.entity.js +0 -153
- package/cjs/entities/user-token.entity.js +0 -120
- package/cjs/enums/index.js +0 -19
- package/cjs/enums/social-provider-type.enum.js +0 -17
- package/cjs/enums/user-org-permission-type.enum.js +0 -15
- package/cjs/helpers/auth-response.mapper.js +0 -46
- package/cjs/helpers/auth-response.mapper.spec.js +0 -139
- package/cjs/helpers/index.js +0 -19
- package/cjs/helpers/token.helper.js +0 -58
- package/cjs/helpers/token.helper.spec.js +0 -86
- package/cjs/index.js +0 -30
- package/cjs/interceptors/clear-token.interceptor.js +0 -73
- package/cjs/interceptors/clear-token.interceptor.spec.js +0 -107
- package/cjs/interceptors/index.js +0 -19
- package/cjs/interceptors/set-token.interceptor.js +0 -107
- package/cjs/interceptors/set-token.interceptor.spec.js +0 -165
- package/cjs/interfaces/auth-email-provider.interface.js +0 -45
- package/cjs/interfaces/auth-module-options.interface.js +0 -4
- package/cjs/interfaces/authentication.interface.js +0 -4
- package/cjs/interfaces/company-branch.interface.js +0 -4
- package/cjs/interfaces/company.interface.js +0 -4
- package/cjs/interfaces/index.js +0 -25
- package/cjs/interfaces/social-auth.interface.js +0 -4
- package/cjs/interfaces/user-enricher.interface.js +0 -4
- package/cjs/interfaces/user.interface.js +0 -4
- package/cjs/modules/auth.module.js +0 -208
- package/cjs/modules/auth.module.spec.js +0 -258
- package/cjs/modules/index.js +0 -18
- package/cjs/providers/facebook.social-provider.js +0 -73
- package/cjs/providers/google.social-provider.js +0 -68
- package/cjs/providers/index.js +0 -18
- package/cjs/providers/linkedin.social-provider.js +0 -66
- package/cjs/providers/microsoft.social-provider.js +0 -78
- package/cjs/providers/oauth-http.util.js +0 -107
- package/cjs/providers/social-provider.registry.js +0 -24
- package/cjs/providers/social-provider.registry.spec.js +0 -135
- package/cjs/services/auth-config.service.js +0 -113
- package/cjs/services/auth-config.service.spec.js +0 -100
- package/cjs/services/auth-datasource.provider.js +0 -138
- package/cjs/services/auth-datasource.provider.spec.js +0 -191
- package/cjs/services/auth-email.service.js +0 -539
- package/cjs/services/auth-email.service.spec.js +0 -456
- package/cjs/services/authentication.service.js +0 -1203
- package/cjs/services/authentication.service.spec.js +0 -1020
- package/cjs/services/branch.service.js +0 -153
- package/cjs/services/branch.service.spec.js +0 -169
- package/cjs/services/company-selection-session.service.js +0 -121
- package/cjs/services/company-selection-session.service.spec.js +0 -90
- package/cjs/services/company.service.js +0 -140
- package/cjs/services/company.service.spec.js +0 -127
- package/cjs/services/index.js +0 -28
- package/cjs/services/social-auth-config.service.js +0 -103
- package/cjs/services/social-auth-config.service.spec.js +0 -71
- package/cjs/services/social-auth.service.js +0 -310
- package/cjs/services/social-auth.service.spec.js +0 -310
- package/cjs/services/user-permission.service.js +0 -236
- package/cjs/services/user-permission.service.spec.js +0 -254
- package/cjs/services/user.service.js +0 -671
- package/cjs/services/user.service.spec.js +0 -718
- package/cjs/strategies/jwt.strategy.js +0 -140
- package/cjs/strategies/jwt.strategy.spec.js +0 -166
- package/cjs/validators/password.validator.js +0 -45
- package/cjs/validators/password.validator.spec.js +0 -161
- package/fesm/config/auth.constants.js +0 -14
- package/fesm/config/event-actions.js +0 -26
- package/fesm/config/message-keys.js +0 -99
- package/fesm/controllers/authentication.controller.js +0 -417
- package/fesm/controllers/authentication.controller.spec.js +0 -215
- package/fesm/controllers/branch.controller.js +0 -92
- package/fesm/controllers/branch.controller.spec.js +0 -130
- package/fesm/controllers/company-selection.controller.js +0 -188
- package/fesm/controllers/company-selection.controller.spec.js +0 -80
- package/fesm/controllers/company.controller.js +0 -92
- package/fesm/controllers/company.controller.spec.js +0 -127
- package/fesm/controllers/email-verification.controller.js +0 -214
- package/fesm/controllers/email-verification.controller.spec.js +0 -138
- package/fesm/controllers/social-auth-config.controller.js +0 -97
- package/fesm/controllers/social-auth.controller.js +0 -165
- package/fesm/controllers/social-auth.controller.spec.js +0 -75
- package/fesm/controllers/user-permission.controller.js +0 -213
- package/fesm/controllers/user-permission.controller.spec.js +0 -134
- package/fesm/controllers/user.controller.js +0 -428
- package/fesm/controllers/user.controller.spec.js +0 -200
- package/fesm/docs/auth-swagger.config.js +0 -454
- package/fesm/docs/auth-swagger.config.spec.js +0 -126
- package/fesm/dtos/authentication.dto.js +0 -683
- package/fesm/dtos/company-branch.dto.js +0 -279
- package/fesm/dtos/company.dto.js +0 -283
- package/fesm/dtos/social-auth.dto.js +0 -282
- package/fesm/dtos/user-permission.dto.js +0 -339
- package/fesm/dtos/user.dto.js +0 -391
- package/fesm/entities/app-user.entity.js +0 -15
- package/fesm/entities/company-branch.entity.js +0 -153
- package/fesm/entities/company.entity.js +0 -136
- package/fesm/entities/index.spec.js +0 -80
- package/fesm/entities/pending-registration.entity.js +0 -125
- package/fesm/entities/social-auth-config.entity.js +0 -92
- package/fesm/entities/user-company-permission.entity.js +0 -136
- package/fesm/entities/user-token.entity.js +0 -104
- package/fesm/enums/social-provider-type.enum.js +0 -7
- package/fesm/enums/user-org-permission-type.enum.js +0 -5
- package/fesm/helpers/auth-response.mapper.js +0 -25
- package/fesm/helpers/auth-response.mapper.spec.js +0 -135
- package/fesm/helpers/token.helper.js +0 -40
- package/fesm/helpers/token.helper.spec.js +0 -82
- package/fesm/interceptors/clear-token.interceptor.js +0 -63
- package/fesm/interceptors/clear-token.interceptor.spec.js +0 -103
- package/fesm/interceptors/set-token.interceptor.js +0 -98
- package/fesm/interceptors/set-token.interceptor.spec.js +0 -161
- package/fesm/interfaces/auth-email-provider.interface.js +0 -38
- package/fesm/interfaces/auth-module-options.interface.js +0 -3
- package/fesm/interfaces/authentication.interface.js +0 -1
- package/fesm/interfaces/company-branch.interface.js +0 -1
- package/fesm/interfaces/company.interface.js +0 -1
- package/fesm/interfaces/social-auth.interface.js +0 -1
- package/fesm/interfaces/user-enricher.interface.js +0 -4
- package/fesm/interfaces/user.interface.js +0 -1
- package/fesm/modules/auth.module.js +0 -198
- package/fesm/modules/auth.module.spec.js +0 -254
- package/fesm/providers/facebook.social-provider.js +0 -63
- package/fesm/providers/google.social-provider.js +0 -58
- package/fesm/providers/index.js +0 -1
- package/fesm/providers/linkedin.social-provider.js +0 -56
- package/fesm/providers/microsoft.social-provider.js +0 -68
- package/fesm/providers/oauth-http.util.js +0 -77
- package/fesm/providers/social-provider.registry.js +0 -14
- package/fesm/providers/social-provider.registry.spec.js +0 -131
- package/fesm/services/auth-config.service.js +0 -103
- package/fesm/services/auth-config.service.spec.js +0 -96
- package/fesm/services/auth-datasource.provider.js +0 -87
- package/fesm/services/auth-datasource.provider.spec.js +0 -187
- package/fesm/services/auth-email.service.js +0 -488
- package/fesm/services/auth-email.service.spec.js +0 -411
- package/fesm/services/authentication.service.js +0 -1152
- package/fesm/services/authentication.service.spec.js +0 -975
- package/fesm/services/branch.service.js +0 -143
- package/fesm/services/branch.service.spec.js +0 -165
- package/fesm/services/company-selection-session.service.js +0 -111
- package/fesm/services/company-selection-session.service.spec.js +0 -86
- package/fesm/services/company.service.js +0 -130
- package/fesm/services/company.service.spec.js +0 -123
- package/fesm/services/social-auth-config.service.js +0 -93
- package/fesm/services/social-auth-config.service.spec.js +0 -67
- package/fesm/services/social-auth.service.js +0 -300
- package/fesm/services/social-auth.service.spec.js +0 -265
- package/fesm/services/user-permission.service.js +0 -226
- package/fesm/services/user-permission.service.spec.js +0 -250
- package/fesm/services/user.service.js +0 -620
- package/fesm/services/user.service.spec.js +0 -673
- package/fesm/strategies/jwt.strategy.js +0 -130
- package/fesm/strategies/jwt.strategy.spec.js +0 -162
- package/fesm/validators/password.validator.js +0 -48
- package/fesm/validators/password.validator.spec.js +0 -157
package/fesm/120.js
ADDED
|
@@ -0,0 +1,2265 @@
|
|
|
1
|
+
import * as __rspack_external__flusys_nestjs_shared_guards_3f79ddd1 from "@flusys/nestjs-shared/guards";
|
|
2
|
+
import * as __rspack_external_rxjs from "rxjs";
|
|
3
|
+
import * as __rspack_external__flusys_nestjs_shared_decorators_c129b601 from "@flusys/nestjs-shared/decorators";
|
|
4
|
+
import * as __rspack_external__nestjs_throttler_68da00c9 from "@nestjs/throttler";
|
|
5
|
+
import * as __rspack_external_buffer from "buffer";
|
|
6
|
+
export const __rspack_esm_id = 120;
|
|
7
|
+
export const __rspack_esm_ids = [120];
|
|
8
|
+
export const __webpack_modules__ = {
|
|
9
|
+
1003(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
10
|
+
|
|
11
|
+
// EXPORTS
|
|
12
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
13
|
+
$3: () => (/* reexport */ AuthenticationController),
|
|
14
|
+
zF: () => (/* reexport */ BranchController),
|
|
15
|
+
wD: () => (/* reexport */ CompanyController),
|
|
16
|
+
Qg: () => (/* reexport */ CompanySelectionController),
|
|
17
|
+
Q1: () => (/* reexport */ EmailVerificationController),
|
|
18
|
+
O3: () => (/* reexport */ SocialAuthConfigController),
|
|
19
|
+
eA: () => (/* reexport */ SocialAuthController),
|
|
20
|
+
SZ: () => (/* reexport */ UserController),
|
|
21
|
+
rl: () => (/* reexport */ UserPermissionController)
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// EXTERNAL MODULE: external "@flusys/nestjs-shared"
|
|
25
|
+
var nestjs_shared_ = __webpack_require__(3422);
|
|
26
|
+
;// CONCATENATED MODULE: external "@flusys/nestjs-shared/decorators"
|
|
27
|
+
|
|
28
|
+
// EXTERNAL MODULE: external "@flusys/nestjs-shared/dtos"
|
|
29
|
+
var dtos_ = __webpack_require__(6873);
|
|
30
|
+
// EXTERNAL MODULE: external "@flusys/nestjs-shared/guards"
|
|
31
|
+
var guards_ = __webpack_require__(3513);
|
|
32
|
+
// EXTERNAL MODULE: external "@nestjs/common"
|
|
33
|
+
var common_ = __webpack_require__(6157);
|
|
34
|
+
// EXTERNAL MODULE: external "@nestjs/swagger"
|
|
35
|
+
var swagger_ = __webpack_require__(6176);
|
|
36
|
+
;// CONCATENATED MODULE: external "@nestjs/throttler"
|
|
37
|
+
|
|
38
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/config/message-keys.ts
|
|
39
|
+
var message_keys = __webpack_require__(5363);
|
|
40
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/config/auth.constants.ts
|
|
41
|
+
var auth_constants = __webpack_require__(5588);
|
|
42
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/dtos/authentication.dto.ts
|
|
43
|
+
var authentication_dto = __webpack_require__(8978);
|
|
44
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/interceptors/clear-token.interceptor.ts
|
|
45
|
+
var clear_token_interceptor = __webpack_require__(5207);
|
|
46
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/interceptors/set-token.interceptor.ts + 1 modules
|
|
47
|
+
var set_token_interceptor = __webpack_require__(8359);
|
|
48
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/services/auth-config.service.ts + 1 modules
|
|
49
|
+
var auth_config_service = __webpack_require__(6514);
|
|
50
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/services/authentication.service.ts + 1 modules
|
|
51
|
+
var authentication_service = __webpack_require__(4722);
|
|
52
|
+
;// CONCATENATED MODULE: ./projects/nestjs-auth/src/controllers/authentication.controller.ts
|
|
53
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
54
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
55
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
56
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
57
|
+
} else {
|
|
58
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
59
|
+
if (d = decorators[i]) {
|
|
60
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
65
|
+
}
|
|
66
|
+
function _ts_metadata(metadataKey, metadataValue) {
|
|
67
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
68
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function _ts_param(paramIndex, decorator) {
|
|
72
|
+
return function(target, key) {
|
|
73
|
+
decorator(target, key, paramIndex);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class AuthenticationController {
|
|
90
|
+
authService;
|
|
91
|
+
authConfig;
|
|
92
|
+
constructor(authService, authConfig){
|
|
93
|
+
this.authService = authService;
|
|
94
|
+
this.authConfig = authConfig;
|
|
95
|
+
}
|
|
96
|
+
async login(loginDto) {
|
|
97
|
+
const result = await this.authService.login(loginDto.email, loginDto.password);
|
|
98
|
+
if ('requiresEmailVerification' in result) {
|
|
99
|
+
return {
|
|
100
|
+
success: true,
|
|
101
|
+
message: 'Email verification required',
|
|
102
|
+
messageKey: message_keys/* .AUTH_MESSAGES.LOGIN_EMAIL_NOT_VERIFIED */.mK.LOGIN_EMAIL_NOT_VERIFIED,
|
|
103
|
+
data: result
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
if ('requiresSelection' in result) {
|
|
107
|
+
return {
|
|
108
|
+
success: true,
|
|
109
|
+
message: 'Company selection required',
|
|
110
|
+
messageKey: message_keys/* .AUTH_MESSAGES.LOGIN_REQUIRES_SELECTION */.mK.LOGIN_REQUIRES_SELECTION,
|
|
111
|
+
data: result
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
success: true,
|
|
116
|
+
message: 'Login successful',
|
|
117
|
+
messageKey: message_keys/* .AUTH_MESSAGES.LOGIN_SUCCESS */.mK.LOGIN_SUCCESS,
|
|
118
|
+
data: result
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/** Register new user. If company feature enabled, can join/create company. */ async register(req, registrationDto) {
|
|
122
|
+
const verifyUrlBase = (0,nestjs_shared_.buildFrontendUrl)(req, '/auth/verify-email');
|
|
123
|
+
const result = await this.authService.register(registrationDto, verifyUrlBase);
|
|
124
|
+
return {
|
|
125
|
+
success: true,
|
|
126
|
+
message: result.requiresEmailVerification ? 'Verification email sent' : 'Registration successful',
|
|
127
|
+
messageKey: result.requiresEmailVerification ? message_keys/* .EMAIL_VERIFICATION_MESSAGES.VERIFICATION_SENT */.sv.VERIFICATION_SENT : message_keys/* .AUTH_MESSAGES.REGISTER_SUCCESS */.mK.REGISTER_SUCCESS,
|
|
128
|
+
data: result
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Refresh access token.
|
|
133
|
+
* - **Browser**: Prefers HTTP-only cookie, falls back to body if cookie missing.
|
|
134
|
+
* - **API/Mobile**: Must send `refreshToken` in request body. Set header `x-client-type: mobile` or `x-client-type: api`.
|
|
135
|
+
*/ async refreshToken(req, refreshTokenDto) {
|
|
136
|
+
const cookieName = this.authConfig?.getRefreshTokenCookieName() ?? auth_constants/* .DEFAULT_COOKIE_NAME */.rv;
|
|
137
|
+
// Always check cookie first, then body - handles Browser, SSR, and Mobile/API
|
|
138
|
+
const refreshToken = req.cookies?.[cookieName] || refreshTokenDto.refreshToken;
|
|
139
|
+
if (!refreshToken) {
|
|
140
|
+
throw new common_.UnauthorizedException({
|
|
141
|
+
message: 'Refresh token is required',
|
|
142
|
+
messageKey: message_keys/* .AUTH_MESSAGES.TOKEN_REQUIRED */.mK.TOKEN_REQUIRED
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const data = await this.authService.refreshToken(refreshToken);
|
|
146
|
+
return {
|
|
147
|
+
success: true,
|
|
148
|
+
message: 'Token refreshed successfully',
|
|
149
|
+
messageKey: message_keys/* .AUTH_MESSAGES.REFRESH_SUCCESS */.mK.REFRESH_SUCCESS,
|
|
150
|
+
data
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/** Get current user info. Returns user, company, and branch data (no tokens). */ async getCurrentUser(user) {
|
|
154
|
+
const data = await this.authService.getUserInfo(user.id, user.companyId, user.branchId);
|
|
155
|
+
return {
|
|
156
|
+
success: true,
|
|
157
|
+
message: 'User info retrieved successfully',
|
|
158
|
+
messageKey: message_keys/* .AUTH_MESSAGES.ME_SUCCESS */.mK.ME_SUCCESS,
|
|
159
|
+
data
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
/** Logout - Clears refresh token cookie for browsers */ async logout(userId) {
|
|
163
|
+
await this.authService.logout(userId);
|
|
164
|
+
return {
|
|
165
|
+
success: true,
|
|
166
|
+
message: 'Logged out successfully',
|
|
167
|
+
messageKey: message_keys/* .AUTH_MESSAGES.LOGOUT_SUCCESS */.mK.LOGOUT_SUCCESS
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
async changePassword(userId, dto) {
|
|
171
|
+
await this.authService.changePassword(userId, dto.currentPassword, dto.newPassword);
|
|
172
|
+
return {
|
|
173
|
+
success: true,
|
|
174
|
+
message: 'Password changed successfully',
|
|
175
|
+
messageKey: message_keys/* .AUTH_MESSAGES.PASSWORD_CHANGE_SUCCESS */.mK.PASSWORD_CHANGE_SUCCESS
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
_ts_decorate([
|
|
180
|
+
(0,common_.Post)('login'),
|
|
181
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
182
|
+
(0,__rspack_external__nestjs_throttler_68da00c9.Throttle)({
|
|
183
|
+
default: {
|
|
184
|
+
limit: 5,
|
|
185
|
+
ttl: 60000
|
|
186
|
+
}
|
|
187
|
+
}),
|
|
188
|
+
(0,common_.UseInterceptors)(set_token_interceptor/* .SetToken */.A),
|
|
189
|
+
(0,swagger_.ApiOperation)({
|
|
190
|
+
summary: 'User login'
|
|
191
|
+
}),
|
|
192
|
+
(0,swagger_.ApiBody)({
|
|
193
|
+
type: authentication_dto/* .LoginDto */.pb
|
|
194
|
+
}),
|
|
195
|
+
(0,swagger_.ApiResponse)({
|
|
196
|
+
status: 200,
|
|
197
|
+
description: 'Login successful, requires company selection, or requires email verification',
|
|
198
|
+
content: {
|
|
199
|
+
'application/json': {
|
|
200
|
+
examples: {
|
|
201
|
+
loginSuccess: {
|
|
202
|
+
summary: 'Login Success',
|
|
203
|
+
value: {
|
|
204
|
+
success: true,
|
|
205
|
+
message: 'Login successful',
|
|
206
|
+
messageKey: 'auth.login.success',
|
|
207
|
+
data: {
|
|
208
|
+
accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
|
|
209
|
+
user: {
|
|
210
|
+
id: '550e8400-e29b-41d4-a716-446655440000',
|
|
211
|
+
email: 'john@example.com',
|
|
212
|
+
name: 'John Doe'
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
loginSuccessWithCompany: {
|
|
218
|
+
summary: 'Login Success (with company/branch)',
|
|
219
|
+
value: {
|
|
220
|
+
success: true,
|
|
221
|
+
message: 'Login successful',
|
|
222
|
+
messageKey: 'auth.login.success',
|
|
223
|
+
data: {
|
|
224
|
+
accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
|
|
225
|
+
user: {
|
|
226
|
+
id: '550e8400-e29b-41d4-a716-446655440000',
|
|
227
|
+
email: 'john@example.com',
|
|
228
|
+
name: 'John Doe'
|
|
229
|
+
},
|
|
230
|
+
company: {
|
|
231
|
+
id: 'company-id',
|
|
232
|
+
name: 'Acme Corp'
|
|
233
|
+
},
|
|
234
|
+
branch: {
|
|
235
|
+
id: 'branch-id',
|
|
236
|
+
name: 'Main Branch'
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
companySelection: {
|
|
242
|
+
summary: 'Company Selection Required',
|
|
243
|
+
value: {
|
|
244
|
+
success: true,
|
|
245
|
+
message: 'Company selection required',
|
|
246
|
+
messageKey: 'auth.login.requires.selection',
|
|
247
|
+
data: {
|
|
248
|
+
requiresSelection: true,
|
|
249
|
+
sessionId: 'sess_abc123def456',
|
|
250
|
+
expiresAt: '2024-12-18T15:30:00.000Z',
|
|
251
|
+
user: {
|
|
252
|
+
id: '550e8400-e29b-41d4-a716-446655440000',
|
|
253
|
+
email: 'john@example.com'
|
|
254
|
+
},
|
|
255
|
+
companies: [
|
|
256
|
+
{
|
|
257
|
+
id: 'company-id',
|
|
258
|
+
name: 'Acme Corp',
|
|
259
|
+
slug: 'acme-corp',
|
|
260
|
+
branches: [
|
|
261
|
+
{
|
|
262
|
+
id: 'branch-id',
|
|
263
|
+
name: 'Main Branch',
|
|
264
|
+
slug: 'main-branch'
|
|
265
|
+
}
|
|
266
|
+
]
|
|
267
|
+
}
|
|
268
|
+
]
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
emailVerification: {
|
|
273
|
+
summary: 'Email Verification Required',
|
|
274
|
+
value: {
|
|
275
|
+
success: true,
|
|
276
|
+
message: 'Email verification required',
|
|
277
|
+
messageKey: 'auth.login.email.not.verified',
|
|
278
|
+
data: {
|
|
279
|
+
requiresEmailVerification: true,
|
|
280
|
+
email: 'john@example.com'
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}),
|
|
288
|
+
_ts_param(0, (0,common_.Body)()),
|
|
289
|
+
_ts_metadata("design:type", Function),
|
|
290
|
+
_ts_metadata("design:paramtypes", [
|
|
291
|
+
typeof authentication_dto/* .LoginDto */.pb === "undefined" ? Object : authentication_dto/* .LoginDto */.pb
|
|
292
|
+
]),
|
|
293
|
+
_ts_metadata("design:returntype", Promise)
|
|
294
|
+
], AuthenticationController.prototype, "login", null);
|
|
295
|
+
_ts_decorate([
|
|
296
|
+
(0,common_.Post)('register'),
|
|
297
|
+
(0,common_.HttpCode)(common_.HttpStatus.CREATED),
|
|
298
|
+
(0,__rspack_external__nestjs_throttler_68da00c9.Throttle)({
|
|
299
|
+
default: {
|
|
300
|
+
limit: 3,
|
|
301
|
+
ttl: 60000
|
|
302
|
+
}
|
|
303
|
+
}),
|
|
304
|
+
(0,common_.UseInterceptors)(set_token_interceptor/* .SetToken */.A),
|
|
305
|
+
(0,swagger_.ApiOperation)({
|
|
306
|
+
summary: 'Register new user'
|
|
307
|
+
}),
|
|
308
|
+
(0,swagger_.ApiBody)({
|
|
309
|
+
type: authentication_dto/* .RegistrationDto */.xG
|
|
310
|
+
}),
|
|
311
|
+
(0,swagger_.ApiResponse)({
|
|
312
|
+
status: 201,
|
|
313
|
+
description: 'Registration successful or email verification required'
|
|
314
|
+
}),
|
|
315
|
+
_ts_param(0, (0,common_.Req)()),
|
|
316
|
+
_ts_param(1, (0,common_.Body)()),
|
|
317
|
+
_ts_metadata("design:type", Function),
|
|
318
|
+
_ts_metadata("design:paramtypes", [
|
|
319
|
+
typeof Request === "undefined" ? Object : Request,
|
|
320
|
+
typeof authentication_dto/* .RegistrationDto */.xG === "undefined" ? Object : authentication_dto/* .RegistrationDto */.xG
|
|
321
|
+
]),
|
|
322
|
+
_ts_metadata("design:returntype", Promise)
|
|
323
|
+
], AuthenticationController.prototype, "register", null);
|
|
324
|
+
_ts_decorate([
|
|
325
|
+
(0,common_.Post)('refresh'),
|
|
326
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
327
|
+
(0,__rspack_external__nestjs_throttler_68da00c9.Throttle)({
|
|
328
|
+
default: {
|
|
329
|
+
limit: 30,
|
|
330
|
+
ttl: 60000
|
|
331
|
+
}
|
|
332
|
+
}),
|
|
333
|
+
(0,swagger_.ApiOperation)({
|
|
334
|
+
summary: 'Refresh access token',
|
|
335
|
+
description: `
|
|
336
|
+
**Browser clients**: Refresh token is read from HTTP-only cookie (automatically set on login/register).
|
|
337
|
+
Falls back to request body if cookie is not available.
|
|
338
|
+
|
|
339
|
+
**API/Mobile clients**: Must send \`refreshToken\` in request body.
|
|
340
|
+
Set header \`x-client-type: mobile\` or \`x-client-type: api\` to identify as non-browser client.
|
|
341
|
+
|
|
342
|
+
**Client detection**: Uses \`x-client-type\` header first, then falls back to User-Agent detection.
|
|
343
|
+
`
|
|
344
|
+
}),
|
|
345
|
+
(0,swagger_.ApiHeader)({
|
|
346
|
+
name: 'x-client-type',
|
|
347
|
+
required: false,
|
|
348
|
+
description: 'Client type: "browser"/"web" for cookie-based auth, "mobile"/"api" for body-based auth',
|
|
349
|
+
example: 'mobile'
|
|
350
|
+
}),
|
|
351
|
+
(0,swagger_.ApiBody)({
|
|
352
|
+
type: authentication_dto/* .RefreshTokenDto */.k2,
|
|
353
|
+
description: 'Required for API/Mobile clients. Browser clients prefer HTTP-only cookie with body fallback.'
|
|
354
|
+
}),
|
|
355
|
+
(0,swagger_.ApiResponse)({
|
|
356
|
+
status: 200,
|
|
357
|
+
description: 'Token refreshed successfully',
|
|
358
|
+
schema: {
|
|
359
|
+
example: {
|
|
360
|
+
success: true,
|
|
361
|
+
message: 'Token refreshed successfully',
|
|
362
|
+
messageKey: 'auth.refresh.success',
|
|
363
|
+
data: {
|
|
364
|
+
accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}),
|
|
369
|
+
(0,swagger_.ApiResponse)({
|
|
370
|
+
status: 401,
|
|
371
|
+
description: 'Invalid or missing refresh token'
|
|
372
|
+
}),
|
|
373
|
+
_ts_param(0, (0,common_.Req)()),
|
|
374
|
+
_ts_param(1, (0,common_.Body)()),
|
|
375
|
+
_ts_metadata("design:type", Function),
|
|
376
|
+
_ts_metadata("design:paramtypes", [
|
|
377
|
+
typeof Request === "undefined" ? Object : Request,
|
|
378
|
+
typeof authentication_dto/* .RefreshTokenDto */.k2 === "undefined" ? Object : authentication_dto/* .RefreshTokenDto */.k2
|
|
379
|
+
]),
|
|
380
|
+
_ts_metadata("design:returntype", Promise)
|
|
381
|
+
], AuthenticationController.prototype, "refreshToken", null);
|
|
382
|
+
_ts_decorate([
|
|
383
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard),
|
|
384
|
+
(0,common_.Post)('me'),
|
|
385
|
+
(0,__rspack_external__nestjs_throttler_68da00c9.SkipThrottle)(),
|
|
386
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
387
|
+
(0,swagger_.ApiOperation)({
|
|
388
|
+
summary: 'Get current user info'
|
|
389
|
+
}),
|
|
390
|
+
(0,swagger_.ApiResponse)({
|
|
391
|
+
status: 200,
|
|
392
|
+
description: 'Current user info retrieved successfully'
|
|
393
|
+
}),
|
|
394
|
+
_ts_param(0, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)()),
|
|
395
|
+
_ts_metadata("design:type", Function),
|
|
396
|
+
_ts_metadata("design:paramtypes", [
|
|
397
|
+
typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
|
|
398
|
+
]),
|
|
399
|
+
_ts_metadata("design:returntype", Promise)
|
|
400
|
+
], AuthenticationController.prototype, "getCurrentUser", null);
|
|
401
|
+
_ts_decorate([
|
|
402
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard),
|
|
403
|
+
(0,common_.Post)('logout'),
|
|
404
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
405
|
+
(0,__rspack_external__nestjs_throttler_68da00c9.SkipThrottle)(),
|
|
406
|
+
(0,common_.UseInterceptors)(clear_token_interceptor/* .ClearToken */.t),
|
|
407
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
408
|
+
(0,swagger_.ApiOperation)({
|
|
409
|
+
summary: 'Logout user'
|
|
410
|
+
}),
|
|
411
|
+
(0,swagger_.ApiResponse)({
|
|
412
|
+
status: 200,
|
|
413
|
+
type: dtos_.MessageResponseDto
|
|
414
|
+
}),
|
|
415
|
+
_ts_param(0, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)('id')),
|
|
416
|
+
_ts_metadata("design:type", Function),
|
|
417
|
+
_ts_metadata("design:paramtypes", [
|
|
418
|
+
String
|
|
419
|
+
]),
|
|
420
|
+
_ts_metadata("design:returntype", Promise)
|
|
421
|
+
], AuthenticationController.prototype, "logout", null);
|
|
422
|
+
_ts_decorate([
|
|
423
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard),
|
|
424
|
+
(0,common_.Post)('change-password'),
|
|
425
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
426
|
+
(0,__rspack_external__nestjs_throttler_68da00c9.Throttle)({
|
|
427
|
+
default: {
|
|
428
|
+
limit: 5,
|
|
429
|
+
ttl: 60000
|
|
430
|
+
}
|
|
431
|
+
}),
|
|
432
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
433
|
+
(0,swagger_.ApiOperation)({
|
|
434
|
+
summary: 'Change password'
|
|
435
|
+
}),
|
|
436
|
+
(0,swagger_.ApiBody)({
|
|
437
|
+
type: authentication_dto/* .ChangePasswordDto */.$h
|
|
438
|
+
}),
|
|
439
|
+
(0,swagger_.ApiResponse)({
|
|
440
|
+
status: 200,
|
|
441
|
+
type: dtos_.MessageResponseDto
|
|
442
|
+
}),
|
|
443
|
+
_ts_param(0, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)('id')),
|
|
444
|
+
_ts_param(1, (0,common_.Body)()),
|
|
445
|
+
_ts_metadata("design:type", Function),
|
|
446
|
+
_ts_metadata("design:paramtypes", [
|
|
447
|
+
String,
|
|
448
|
+
typeof authentication_dto/* .ChangePasswordDto */.$h === "undefined" ? Object : authentication_dto/* .ChangePasswordDto */.$h
|
|
449
|
+
]),
|
|
450
|
+
_ts_metadata("design:returntype", Promise)
|
|
451
|
+
], AuthenticationController.prototype, "changePassword", null);
|
|
452
|
+
AuthenticationController = _ts_decorate([
|
|
453
|
+
(0,swagger_.ApiTags)('Authentication'),
|
|
454
|
+
(0,common_.Controller)('auth'),
|
|
455
|
+
_ts_param(0, (0,common_.Inject)(authentication_service/* .AuthenticationService */.k)),
|
|
456
|
+
_ts_param(1, (0,common_.Optional)()),
|
|
457
|
+
_ts_param(1, (0,common_.Inject)(auth_config_service/* .AuthConfigService */.W)),
|
|
458
|
+
_ts_metadata("design:type", Function),
|
|
459
|
+
_ts_metadata("design:paramtypes", [
|
|
460
|
+
typeof authentication_service/* .AuthenticationService */.k === "undefined" ? Object : authentication_service/* .AuthenticationService */.k,
|
|
461
|
+
typeof auth_config_service/* .AuthConfigService */.W === "undefined" ? Object : auth_config_service/* .AuthConfigService */.W
|
|
462
|
+
])
|
|
463
|
+
], AuthenticationController);
|
|
464
|
+
|
|
465
|
+
;// CONCATENATED MODULE: ./projects/nestjs-auth/src/controllers/company-selection.controller.ts
|
|
466
|
+
function company_selection_controller_ts_decorate(decorators, target, key, desc) {
|
|
467
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
468
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
469
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
470
|
+
} else {
|
|
471
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
472
|
+
if (d = decorators[i]) {
|
|
473
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
478
|
+
}
|
|
479
|
+
function company_selection_controller_ts_metadata(metadataKey, metadataValue) {
|
|
480
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
481
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
function company_selection_controller_ts_param(paramIndex, decorator) {
|
|
485
|
+
return function(target, key) {
|
|
486
|
+
decorator(target, key, paramIndex);
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
class CompanySelectionController {
|
|
498
|
+
authService;
|
|
499
|
+
constructor(authService){
|
|
500
|
+
this.authService = authService;
|
|
501
|
+
}
|
|
502
|
+
async select(dto) {
|
|
503
|
+
const data = await this.authService.select(dto.sessionId, dto.companyId, dto.branchId);
|
|
504
|
+
return {
|
|
505
|
+
success: true,
|
|
506
|
+
message: 'Company selected successfully',
|
|
507
|
+
messageKey: message_keys/* .AUTH_MESSAGES.SELECT_SUCCESS */.mK.SELECT_SUCCESS,
|
|
508
|
+
data
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
async switchCompany(userId, dto) {
|
|
512
|
+
const data = await this.authService.switchCompany(userId, dto.companyId, dto.branchId);
|
|
513
|
+
return {
|
|
514
|
+
success: true,
|
|
515
|
+
message: 'Company switched successfully',
|
|
516
|
+
messageKey: message_keys/* .AUTH_MESSAGES.SWITCH_COMPANY_SUCCESS */.mK.SWITCH_COMPANY_SUCCESS,
|
|
517
|
+
data
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
async getUserCompanies(userId) {
|
|
521
|
+
const companies = await this.authService.getUserCompanies(userId);
|
|
522
|
+
return {
|
|
523
|
+
success: true,
|
|
524
|
+
message: 'User companies retrieved successfully',
|
|
525
|
+
messageKey: message_keys/* .AUTH_MESSAGES.COMPANY_LIST_SUCCESS */.mK.COMPANY_LIST_SUCCESS,
|
|
526
|
+
data: companies
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
async getUserBranches(userId, companyId) {
|
|
530
|
+
const branches = await this.authService.getUserBranches(userId, companyId);
|
|
531
|
+
return {
|
|
532
|
+
success: true,
|
|
533
|
+
message: 'Company branches retrieved successfully',
|
|
534
|
+
messageKey: message_keys/* .AUTH_MESSAGES.BRANCH_LIST_SUCCESS */.mK.BRANCH_LIST_SUCCESS,
|
|
535
|
+
data: branches
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
company_selection_controller_ts_decorate([
|
|
540
|
+
(0,common_.Post)('select'),
|
|
541
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
542
|
+
(0,common_.UseInterceptors)(set_token_interceptor/* .SetToken */.A),
|
|
543
|
+
(0,swagger_.ApiOperation)({
|
|
544
|
+
summary: 'Select company and branch after login',
|
|
545
|
+
description: 'Complete login by selecting company and branch when multiple options are available'
|
|
546
|
+
}),
|
|
547
|
+
(0,swagger_.ApiBody)({
|
|
548
|
+
type: authentication_dto/* .SelectDto */.aZ
|
|
549
|
+
}),
|
|
550
|
+
(0,swagger_.ApiResponse)({
|
|
551
|
+
status: 200,
|
|
552
|
+
description: 'Company selected, tokens returned'
|
|
553
|
+
}),
|
|
554
|
+
company_selection_controller_ts_param(0, (0,common_.Body)()),
|
|
555
|
+
company_selection_controller_ts_metadata("design:type", Function),
|
|
556
|
+
company_selection_controller_ts_metadata("design:paramtypes", [
|
|
557
|
+
typeof authentication_dto/* .SelectDto */.aZ === "undefined" ? Object : authentication_dto/* .SelectDto */.aZ
|
|
558
|
+
]),
|
|
559
|
+
company_selection_controller_ts_metadata("design:returntype", Promise)
|
|
560
|
+
], CompanySelectionController.prototype, "select", null);
|
|
561
|
+
company_selection_controller_ts_decorate([
|
|
562
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard),
|
|
563
|
+
(0,common_.Post)('switch-company'),
|
|
564
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
565
|
+
(0,common_.UseInterceptors)(set_token_interceptor/* .SetToken */.A),
|
|
566
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
567
|
+
(0,swagger_.ApiOperation)({
|
|
568
|
+
summary: 'Switch to different company/branch',
|
|
569
|
+
description: 'Switch to a different company and branch while already authenticated'
|
|
570
|
+
}),
|
|
571
|
+
(0,swagger_.ApiBody)({
|
|
572
|
+
type: authentication_dto/* .SwitchCompanyDto */.RQ
|
|
573
|
+
}),
|
|
574
|
+
(0,swagger_.ApiResponse)({
|
|
575
|
+
status: 200,
|
|
576
|
+
description: 'Company switched, new tokens returned'
|
|
577
|
+
}),
|
|
578
|
+
company_selection_controller_ts_param(0, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)('id')),
|
|
579
|
+
company_selection_controller_ts_param(1, (0,common_.Body)()),
|
|
580
|
+
company_selection_controller_ts_metadata("design:type", Function),
|
|
581
|
+
company_selection_controller_ts_metadata("design:paramtypes", [
|
|
582
|
+
String,
|
|
583
|
+
typeof authentication_dto/* .SwitchCompanyDto */.RQ === "undefined" ? Object : authentication_dto/* .SwitchCompanyDto */.RQ
|
|
584
|
+
]),
|
|
585
|
+
company_selection_controller_ts_metadata("design:returntype", Promise)
|
|
586
|
+
], CompanySelectionController.prototype, "switchCompany", null);
|
|
587
|
+
company_selection_controller_ts_decorate([
|
|
588
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard),
|
|
589
|
+
(0,common_.Post)('get-companies'),
|
|
590
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
591
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
592
|
+
(0,swagger_.ApiOperation)({
|
|
593
|
+
summary: "Get user's available companies",
|
|
594
|
+
description: 'Get list of companies the current user has access to'
|
|
595
|
+
}),
|
|
596
|
+
(0,swagger_.ApiResponse)({
|
|
597
|
+
status: 200,
|
|
598
|
+
description: 'User companies retrieved successfully'
|
|
599
|
+
}),
|
|
600
|
+
company_selection_controller_ts_param(0, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)('id')),
|
|
601
|
+
company_selection_controller_ts_metadata("design:type", Function),
|
|
602
|
+
company_selection_controller_ts_metadata("design:paramtypes", [
|
|
603
|
+
String
|
|
604
|
+
]),
|
|
605
|
+
company_selection_controller_ts_metadata("design:returntype", Promise)
|
|
606
|
+
], CompanySelectionController.prototype, "getUserCompanies", null);
|
|
607
|
+
company_selection_controller_ts_decorate([
|
|
608
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard),
|
|
609
|
+
(0,common_.Post)('get-company-branches'),
|
|
610
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
611
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
612
|
+
(0,swagger_.ApiOperation)({
|
|
613
|
+
summary: 'Get branches for a company',
|
|
614
|
+
description: 'Get list of branches for a specific company that the user has access to'
|
|
615
|
+
}),
|
|
616
|
+
(0,swagger_.ApiBody)({
|
|
617
|
+
schema: {
|
|
618
|
+
properties: {
|
|
619
|
+
companyId: {
|
|
620
|
+
type: 'string'
|
|
621
|
+
}
|
|
622
|
+
},
|
|
623
|
+
required: [
|
|
624
|
+
'companyId'
|
|
625
|
+
]
|
|
626
|
+
}
|
|
627
|
+
}),
|
|
628
|
+
(0,swagger_.ApiResponse)({
|
|
629
|
+
status: 200,
|
|
630
|
+
description: 'Company branches retrieved successfully'
|
|
631
|
+
}),
|
|
632
|
+
company_selection_controller_ts_param(0, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)('id')),
|
|
633
|
+
company_selection_controller_ts_param(1, (0,common_.Body)('companyId')),
|
|
634
|
+
company_selection_controller_ts_metadata("design:type", Function),
|
|
635
|
+
company_selection_controller_ts_metadata("design:paramtypes", [
|
|
636
|
+
String,
|
|
637
|
+
String
|
|
638
|
+
]),
|
|
639
|
+
company_selection_controller_ts_metadata("design:returntype", Promise)
|
|
640
|
+
], CompanySelectionController.prototype, "getUserBranches", null);
|
|
641
|
+
CompanySelectionController = company_selection_controller_ts_decorate([
|
|
642
|
+
(0,swagger_.ApiTags)('Company Selection'),
|
|
643
|
+
(0,common_.Controller)('auth'),
|
|
644
|
+
company_selection_controller_ts_param(0, (0,common_.Inject)(authentication_service/* .AuthenticationService */.k)),
|
|
645
|
+
company_selection_controller_ts_metadata("design:type", Function),
|
|
646
|
+
company_selection_controller_ts_metadata("design:paramtypes", [
|
|
647
|
+
typeof authentication_service/* .AuthenticationService */.k === "undefined" ? Object : authentication_service/* .AuthenticationService */.k
|
|
648
|
+
])
|
|
649
|
+
], CompanySelectionController);
|
|
650
|
+
|
|
651
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/services/auth-datasource.provider.ts
|
|
652
|
+
var auth_datasource_provider = __webpack_require__(2732);
|
|
653
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/services/auth-email.service.ts
|
|
654
|
+
var auth_email_service = __webpack_require__(3221);
|
|
655
|
+
;// CONCATENATED MODULE: ./projects/nestjs-auth/src/controllers/email-verification.controller.ts
|
|
656
|
+
function email_verification_controller_ts_decorate(decorators, target, key, desc) {
|
|
657
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
658
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
659
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
660
|
+
} else {
|
|
661
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
662
|
+
if (d = decorators[i]) {
|
|
663
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
668
|
+
}
|
|
669
|
+
function email_verification_controller_ts_metadata(metadataKey, metadataValue) {
|
|
670
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
671
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
function email_verification_controller_ts_param(paramIndex, decorator) {
|
|
675
|
+
return function(target, key) {
|
|
676
|
+
decorator(target, key, paramIndex);
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
class EmailVerificationController {
|
|
692
|
+
authService;
|
|
693
|
+
authEmailService;
|
|
694
|
+
authConfig;
|
|
695
|
+
dataSourceProvider;
|
|
696
|
+
constructor(authService, authEmailService, authConfig, dataSourceProvider){
|
|
697
|
+
this.authService = authService;
|
|
698
|
+
this.authEmailService = authEmailService;
|
|
699
|
+
this.authConfig = authConfig;
|
|
700
|
+
this.dataSourceProvider = dataSourceProvider;
|
|
701
|
+
}
|
|
702
|
+
ensureEmailVerificationEnabled() {
|
|
703
|
+
if (!this.dataSourceProvider.isEmailVerificationEnabled()) {
|
|
704
|
+
throw new common_.BadRequestException({
|
|
705
|
+
message: 'Email verification is not enabled for this tenant',
|
|
706
|
+
messageKey: message_keys/* .EMAIL_VERIFICATION_MESSAGES.VERIFICATION_NOT_ENABLED */.sv.VERIFICATION_NOT_ENABLED
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
async forgotPassword(req, dto) {
|
|
711
|
+
this.ensureEmailVerificationEnabled();
|
|
712
|
+
return this.authEmailService.forgotPassword(dto.email, (0,nestjs_shared_.buildFrontendUrl)(req, '/auth/reset-password'));
|
|
713
|
+
}
|
|
714
|
+
async resetPassword(dto) {
|
|
715
|
+
this.ensureEmailVerificationEnabled();
|
|
716
|
+
return this.authEmailService.resetPassword(dto.token, dto.newPassword);
|
|
717
|
+
}
|
|
718
|
+
async resendVerification(req, dto) {
|
|
719
|
+
this.ensureEmailVerificationEnabled();
|
|
720
|
+
return this.authEmailService.resendVerificationEmail(dto.email, (0,nestjs_shared_.buildFrontendUrl)(req, '/auth/verify-email'));
|
|
721
|
+
}
|
|
722
|
+
async verifyEmail(dto) {
|
|
723
|
+
this.ensureEmailVerificationEnabled();
|
|
724
|
+
const result = await this.authEmailService.verifyEmail(dto.token);
|
|
725
|
+
if (result.type === 'pending') {
|
|
726
|
+
const data = await this.authService.createUserFromPendingRegistration(result.pending);
|
|
727
|
+
return {
|
|
728
|
+
success: true,
|
|
729
|
+
message: 'Registration completed successfully',
|
|
730
|
+
messageKey: message_keys/* .AUTH_MESSAGES.REGISTER_SUCCESS */.mK.REGISTER_SUCCESS,
|
|
731
|
+
data
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
return {
|
|
735
|
+
success: true,
|
|
736
|
+
message: result.message,
|
|
737
|
+
messageKey: result.messageKey
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
email_verification_controller_ts_decorate([
|
|
742
|
+
(0,common_.Post)('forgot-password'),
|
|
743
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
744
|
+
(0,__rspack_external__nestjs_throttler_68da00c9.Throttle)({
|
|
745
|
+
default: {
|
|
746
|
+
limit: 3,
|
|
747
|
+
ttl: 300000
|
|
748
|
+
}
|
|
749
|
+
}),
|
|
750
|
+
(0,swagger_.ApiOperation)({
|
|
751
|
+
summary: 'Request password reset email'
|
|
752
|
+
}),
|
|
753
|
+
(0,swagger_.ApiBody)({
|
|
754
|
+
type: authentication_dto/* .ForgotPasswordDto */.mG
|
|
755
|
+
}),
|
|
756
|
+
(0,swagger_.ApiResponse)({
|
|
757
|
+
status: 200,
|
|
758
|
+
type: dtos_.MessageResponseDto
|
|
759
|
+
}),
|
|
760
|
+
email_verification_controller_ts_param(0, (0,common_.Req)()),
|
|
761
|
+
email_verification_controller_ts_param(1, (0,common_.Body)()),
|
|
762
|
+
email_verification_controller_ts_metadata("design:type", Function),
|
|
763
|
+
email_verification_controller_ts_metadata("design:paramtypes", [
|
|
764
|
+
typeof Request === "undefined" ? Object : Request,
|
|
765
|
+
typeof authentication_dto/* .ForgotPasswordDto */.mG === "undefined" ? Object : authentication_dto/* .ForgotPasswordDto */.mG
|
|
766
|
+
]),
|
|
767
|
+
email_verification_controller_ts_metadata("design:returntype", Promise)
|
|
768
|
+
], EmailVerificationController.prototype, "forgotPassword", null);
|
|
769
|
+
email_verification_controller_ts_decorate([
|
|
770
|
+
(0,common_.Post)('reset-password'),
|
|
771
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
772
|
+
(0,__rspack_external__nestjs_throttler_68da00c9.Throttle)({
|
|
773
|
+
default: {
|
|
774
|
+
limit: 5,
|
|
775
|
+
ttl: 900000
|
|
776
|
+
}
|
|
777
|
+
}),
|
|
778
|
+
(0,swagger_.ApiOperation)({
|
|
779
|
+
summary: 'Reset password using token'
|
|
780
|
+
}),
|
|
781
|
+
(0,swagger_.ApiBody)({
|
|
782
|
+
type: authentication_dto/* .ResetPasswordDto */.US
|
|
783
|
+
}),
|
|
784
|
+
(0,swagger_.ApiResponse)({
|
|
785
|
+
status: 200,
|
|
786
|
+
type: dtos_.MessageResponseDto
|
|
787
|
+
}),
|
|
788
|
+
email_verification_controller_ts_param(0, (0,common_.Body)()),
|
|
789
|
+
email_verification_controller_ts_metadata("design:type", Function),
|
|
790
|
+
email_verification_controller_ts_metadata("design:paramtypes", [
|
|
791
|
+
typeof authentication_dto/* .ResetPasswordDto */.US === "undefined" ? Object : authentication_dto/* .ResetPasswordDto */.US
|
|
792
|
+
]),
|
|
793
|
+
email_verification_controller_ts_metadata("design:returntype", Promise)
|
|
794
|
+
], EmailVerificationController.prototype, "resetPassword", null);
|
|
795
|
+
email_verification_controller_ts_decorate([
|
|
796
|
+
(0,common_.Post)('resend-verification'),
|
|
797
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
798
|
+
(0,__rspack_external__nestjs_throttler_68da00c9.Throttle)({
|
|
799
|
+
default: {
|
|
800
|
+
limit: 3,
|
|
801
|
+
ttl: 300000
|
|
802
|
+
}
|
|
803
|
+
}),
|
|
804
|
+
(0,swagger_.ApiOperation)({
|
|
805
|
+
summary: 'Resend email verification link'
|
|
806
|
+
}),
|
|
807
|
+
(0,swagger_.ApiBody)({
|
|
808
|
+
type: authentication_dto/* .ResendVerificationDto */.Oz
|
|
809
|
+
}),
|
|
810
|
+
(0,swagger_.ApiResponse)({
|
|
811
|
+
status: 200,
|
|
812
|
+
type: dtos_.MessageResponseDto
|
|
813
|
+
}),
|
|
814
|
+
email_verification_controller_ts_param(0, (0,common_.Req)()),
|
|
815
|
+
email_verification_controller_ts_param(1, (0,common_.Body)()),
|
|
816
|
+
email_verification_controller_ts_metadata("design:type", Function),
|
|
817
|
+
email_verification_controller_ts_metadata("design:paramtypes", [
|
|
818
|
+
typeof Request === "undefined" ? Object : Request,
|
|
819
|
+
typeof authentication_dto/* .ResendVerificationDto */.Oz === "undefined" ? Object : authentication_dto/* .ResendVerificationDto */.Oz
|
|
820
|
+
]),
|
|
821
|
+
email_verification_controller_ts_metadata("design:returntype", Promise)
|
|
822
|
+
], EmailVerificationController.prototype, "resendVerification", null);
|
|
823
|
+
email_verification_controller_ts_decorate([
|
|
824
|
+
(0,common_.Post)('verify-email'),
|
|
825
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
826
|
+
(0,__rspack_external__nestjs_throttler_68da00c9.Throttle)({
|
|
827
|
+
default: {
|
|
828
|
+
limit: 10,
|
|
829
|
+
ttl: 60000
|
|
830
|
+
}
|
|
831
|
+
}),
|
|
832
|
+
(0,common_.UseInterceptors)(set_token_interceptor/* .SetToken */.A),
|
|
833
|
+
(0,swagger_.ApiOperation)({
|
|
834
|
+
summary: 'Verify email using token'
|
|
835
|
+
}),
|
|
836
|
+
(0,swagger_.ApiBody)({
|
|
837
|
+
type: authentication_dto/* .VerifyEmailDto */.rl
|
|
838
|
+
}),
|
|
839
|
+
(0,swagger_.ApiResponse)({
|
|
840
|
+
status: 200,
|
|
841
|
+
description: 'Email verified or registration completed'
|
|
842
|
+
}),
|
|
843
|
+
email_verification_controller_ts_param(0, (0,common_.Body)()),
|
|
844
|
+
email_verification_controller_ts_metadata("design:type", Function),
|
|
845
|
+
email_verification_controller_ts_metadata("design:paramtypes", [
|
|
846
|
+
typeof authentication_dto/* .VerifyEmailDto */.rl === "undefined" ? Object : authentication_dto/* .VerifyEmailDto */.rl
|
|
847
|
+
]),
|
|
848
|
+
email_verification_controller_ts_metadata("design:returntype", Promise)
|
|
849
|
+
], EmailVerificationController.prototype, "verifyEmail", null);
|
|
850
|
+
EmailVerificationController = email_verification_controller_ts_decorate([
|
|
851
|
+
(0,swagger_.ApiTags)('Authentication'),
|
|
852
|
+
(0,common_.Controller)('auth'),
|
|
853
|
+
email_verification_controller_ts_param(0, (0,common_.Inject)(authentication_service/* .AuthenticationService */.k)),
|
|
854
|
+
email_verification_controller_ts_param(1, (0,common_.Inject)(auth_email_service/* .AuthEmailService */.G)),
|
|
855
|
+
email_verification_controller_ts_param(2, (0,common_.Inject)(auth_config_service/* .AuthConfigService */.W)),
|
|
856
|
+
email_verification_controller_ts_param(3, (0,common_.Inject)(auth_datasource_provider/* .AuthDataSourceProvider */.v)),
|
|
857
|
+
email_verification_controller_ts_metadata("design:type", Function),
|
|
858
|
+
email_verification_controller_ts_metadata("design:paramtypes", [
|
|
859
|
+
typeof authentication_service/* .AuthenticationService */.k === "undefined" ? Object : authentication_service/* .AuthenticationService */.k,
|
|
860
|
+
typeof auth_email_service/* .AuthEmailService */.G === "undefined" ? Object : auth_email_service/* .AuthEmailService */.G,
|
|
861
|
+
typeof auth_config_service/* .AuthConfigService */.W === "undefined" ? Object : auth_config_service/* .AuthConfigService */.W,
|
|
862
|
+
typeof auth_datasource_provider/* .AuthDataSourceProvider */.v === "undefined" ? Object : auth_datasource_provider/* .AuthDataSourceProvider */.v
|
|
863
|
+
])
|
|
864
|
+
], EmailVerificationController);
|
|
865
|
+
|
|
866
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/dtos/social-auth.dto.ts
|
|
867
|
+
var social_auth_dto = __webpack_require__(430);
|
|
868
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/services/social-auth.service.ts
|
|
869
|
+
var social_auth_service = __webpack_require__(2786);
|
|
870
|
+
;// CONCATENATED MODULE: ./projects/nestjs-auth/src/controllers/social-auth.controller.ts
|
|
871
|
+
function social_auth_controller_ts_decorate(decorators, target, key, desc) {
|
|
872
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
873
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
874
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
875
|
+
} else {
|
|
876
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
877
|
+
if (d = decorators[i]) {
|
|
878
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
883
|
+
}
|
|
884
|
+
function social_auth_controller_ts_metadata(metadataKey, metadataValue) {
|
|
885
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
886
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
function social_auth_controller_ts_param(paramIndex, decorator) {
|
|
890
|
+
return function(target, key) {
|
|
891
|
+
decorator(target, key, paramIndex);
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
class SocialAuthController {
|
|
902
|
+
socialAuthService;
|
|
903
|
+
constructor(socialAuthService){
|
|
904
|
+
this.socialAuthService = socialAuthService;
|
|
905
|
+
}
|
|
906
|
+
async getProviders(dto) {
|
|
907
|
+
const data = await this.socialAuthService.listEnabledProviders(dto.redirectUri);
|
|
908
|
+
return {
|
|
909
|
+
success: true,
|
|
910
|
+
message: 'Social providers retrieved successfully',
|
|
911
|
+
messageKey: message_keys/* .SOCIAL_AUTH_MESSAGES.PROVIDERS_SUCCESS */.OF.PROVIDERS_SUCCESS,
|
|
912
|
+
data
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
async authorize(dto) {
|
|
916
|
+
const data = await this.socialAuthService.createAuthorization(dto.provider, dto.redirectUri);
|
|
917
|
+
return {
|
|
918
|
+
success: true,
|
|
919
|
+
message: 'Authorization URL generated successfully',
|
|
920
|
+
messageKey: message_keys/* .SOCIAL_AUTH_MESSAGES.AUTHORIZE_SUCCESS */.OF.AUTHORIZE_SUCCESS,
|
|
921
|
+
data
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
async callback(dto) {
|
|
925
|
+
const result = await this.socialAuthService.completeLogin(dto.code, dto.state, dto.redirectUri);
|
|
926
|
+
if ('requiresSelection' in result) {
|
|
927
|
+
return {
|
|
928
|
+
success: true,
|
|
929
|
+
message: 'Company selection required',
|
|
930
|
+
messageKey: message_keys/* .AUTH_MESSAGES.LOGIN_REQUIRES_SELECTION */.mK.LOGIN_REQUIRES_SELECTION,
|
|
931
|
+
data: result
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
return {
|
|
935
|
+
success: true,
|
|
936
|
+
message: 'Login successful',
|
|
937
|
+
messageKey: message_keys/* .SOCIAL_AUTH_MESSAGES.LOGIN_SUCCESS */.OF.LOGIN_SUCCESS,
|
|
938
|
+
data: result
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
social_auth_controller_ts_decorate([
|
|
943
|
+
(0,common_.Post)('providers'),
|
|
944
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
945
|
+
(0,__rspack_external__nestjs_throttler_68da00c9.Throttle)({
|
|
946
|
+
default: {
|
|
947
|
+
limit: 30,
|
|
948
|
+
ttl: 60000
|
|
949
|
+
}
|
|
950
|
+
}),
|
|
951
|
+
(0,swagger_.ApiOperation)({
|
|
952
|
+
summary: 'List enabled social sign-in providers'
|
|
953
|
+
}),
|
|
954
|
+
(0,swagger_.ApiBody)({
|
|
955
|
+
type: social_auth_dto/* .SocialProvidersDto */.fP
|
|
956
|
+
}),
|
|
957
|
+
(0,swagger_.ApiResponse)({
|
|
958
|
+
status: 200,
|
|
959
|
+
type: [
|
|
960
|
+
social_auth_dto/* .SocialProviderInfoDto */.a2
|
|
961
|
+
]
|
|
962
|
+
}),
|
|
963
|
+
social_auth_controller_ts_param(0, (0,common_.Body)()),
|
|
964
|
+
social_auth_controller_ts_metadata("design:type", Function),
|
|
965
|
+
social_auth_controller_ts_metadata("design:paramtypes", [
|
|
966
|
+
typeof social_auth_dto/* .SocialProvidersDto */.fP === "undefined" ? Object : social_auth_dto/* .SocialProvidersDto */.fP
|
|
967
|
+
]),
|
|
968
|
+
social_auth_controller_ts_metadata("design:returntype", Promise)
|
|
969
|
+
], SocialAuthController.prototype, "getProviders", null);
|
|
970
|
+
social_auth_controller_ts_decorate([
|
|
971
|
+
(0,common_.Post)('authorize'),
|
|
972
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
973
|
+
(0,__rspack_external__nestjs_throttler_68da00c9.Throttle)({
|
|
974
|
+
default: {
|
|
975
|
+
limit: 10,
|
|
976
|
+
ttl: 60000
|
|
977
|
+
}
|
|
978
|
+
}),
|
|
979
|
+
(0,swagger_.ApiOperation)({
|
|
980
|
+
summary: "Start a sign-in and get the provider's consent URL"
|
|
981
|
+
}),
|
|
982
|
+
(0,swagger_.ApiBody)({
|
|
983
|
+
type: social_auth_dto/* .SocialAuthorizeDto */.s4
|
|
984
|
+
}),
|
|
985
|
+
(0,swagger_.ApiResponse)({
|
|
986
|
+
status: 200,
|
|
987
|
+
type: social_auth_dto/* .SocialAuthorizeResponseDto */.pd
|
|
988
|
+
}),
|
|
989
|
+
social_auth_controller_ts_param(0, (0,common_.Body)()),
|
|
990
|
+
social_auth_controller_ts_metadata("design:type", Function),
|
|
991
|
+
social_auth_controller_ts_metadata("design:paramtypes", [
|
|
992
|
+
typeof social_auth_dto/* .SocialAuthorizeDto */.s4 === "undefined" ? Object : social_auth_dto/* .SocialAuthorizeDto */.s4
|
|
993
|
+
]),
|
|
994
|
+
social_auth_controller_ts_metadata("design:returntype", Promise)
|
|
995
|
+
], SocialAuthController.prototype, "authorize", null);
|
|
996
|
+
social_auth_controller_ts_decorate([
|
|
997
|
+
(0,common_.Post)('callback'),
|
|
998
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
999
|
+
(0,__rspack_external__nestjs_throttler_68da00c9.Throttle)({
|
|
1000
|
+
default: {
|
|
1001
|
+
limit: 10,
|
|
1002
|
+
ttl: 60000
|
|
1003
|
+
}
|
|
1004
|
+
}),
|
|
1005
|
+
(0,common_.UseInterceptors)(set_token_interceptor/* .SetToken */.A),
|
|
1006
|
+
(0,swagger_.ApiOperation)({
|
|
1007
|
+
summary: 'Complete a social sign-in'
|
|
1008
|
+
}),
|
|
1009
|
+
(0,swagger_.ApiBody)({
|
|
1010
|
+
type: social_auth_dto/* .SocialCallbackDto */.QW
|
|
1011
|
+
}),
|
|
1012
|
+
(0,swagger_.ApiResponse)({
|
|
1013
|
+
status: 200,
|
|
1014
|
+
description: 'Sign-in successful, or company selection is still required'
|
|
1015
|
+
}),
|
|
1016
|
+
social_auth_controller_ts_param(0, (0,common_.Body)()),
|
|
1017
|
+
social_auth_controller_ts_metadata("design:type", Function),
|
|
1018
|
+
social_auth_controller_ts_metadata("design:paramtypes", [
|
|
1019
|
+
typeof social_auth_dto/* .SocialCallbackDto */.QW === "undefined" ? Object : social_auth_dto/* .SocialCallbackDto */.QW
|
|
1020
|
+
]),
|
|
1021
|
+
social_auth_controller_ts_metadata("design:returntype", Promise)
|
|
1022
|
+
], SocialAuthController.prototype, "callback", null);
|
|
1023
|
+
SocialAuthController = social_auth_controller_ts_decorate([
|
|
1024
|
+
(0,swagger_.ApiTags)('Social Authentication'),
|
|
1025
|
+
(0,common_.Controller)('auth/social'),
|
|
1026
|
+
social_auth_controller_ts_param(0, (0,common_.Inject)(social_auth_service/* .SocialAuthService */.J)),
|
|
1027
|
+
social_auth_controller_ts_metadata("design:type", Function),
|
|
1028
|
+
social_auth_controller_ts_metadata("design:paramtypes", [
|
|
1029
|
+
typeof social_auth_service/* .SocialAuthService */.J === "undefined" ? Object : social_auth_service/* .SocialAuthService */.J
|
|
1030
|
+
])
|
|
1031
|
+
], SocialAuthController);
|
|
1032
|
+
|
|
1033
|
+
// EXTERNAL MODULE: external "@flusys/nestjs-shared/classes"
|
|
1034
|
+
var classes_ = __webpack_require__(6937);
|
|
1035
|
+
// EXTERNAL MODULE: external "@flusys/nestjs-shared/constants"
|
|
1036
|
+
var constants_ = __webpack_require__(9140);
|
|
1037
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/services/social-auth-config.service.ts
|
|
1038
|
+
var social_auth_config_service = __webpack_require__(8275);
|
|
1039
|
+
;// CONCATENATED MODULE: ./projects/nestjs-auth/src/controllers/social-auth-config.controller.ts
|
|
1040
|
+
function social_auth_config_controller_ts_decorate(decorators, target, key, desc) {
|
|
1041
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1042
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1043
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1044
|
+
} else {
|
|
1045
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
1046
|
+
if (d = decorators[i]) {
|
|
1047
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1052
|
+
}
|
|
1053
|
+
function social_auth_config_controller_ts_metadata(metadataKey, metadataValue) {
|
|
1054
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1055
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
function social_auth_config_controller_ts_param(paramIndex, decorator) {
|
|
1059
|
+
return function(target, key) {
|
|
1060
|
+
decorator(target, key, paramIndex);
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
|
|
1065
|
+
|
|
1066
|
+
|
|
1067
|
+
|
|
1068
|
+
|
|
1069
|
+
class SocialAuthConfigController extends (0,classes_.createApiController)(social_auth_dto/* .CreateSocialAuthConfigDto */.X8, social_auth_dto/* .UpdateSocialAuthConfigDto */.kd, social_auth_dto/* .SocialAuthConfigResponseDto */.SN, {
|
|
1070
|
+
entityName: 'social.config',
|
|
1071
|
+
security: {
|
|
1072
|
+
insert: {
|
|
1073
|
+
level: 'permission',
|
|
1074
|
+
permissions: [
|
|
1075
|
+
constants_.SOCIAL_AUTH_CONFIG_PERMISSIONS.CREATE
|
|
1076
|
+
]
|
|
1077
|
+
},
|
|
1078
|
+
bulkUpsert: {
|
|
1079
|
+
level: 'permission',
|
|
1080
|
+
permissions: [
|
|
1081
|
+
constants_.SOCIAL_AUTH_CONFIG_PERMISSIONS.CREATE,
|
|
1082
|
+
constants_.SOCIAL_AUTH_CONFIG_PERMISSIONS.UPDATE
|
|
1083
|
+
],
|
|
1084
|
+
operator: 'AND'
|
|
1085
|
+
},
|
|
1086
|
+
getById: {
|
|
1087
|
+
level: 'permission',
|
|
1088
|
+
permissions: [
|
|
1089
|
+
constants_.SOCIAL_AUTH_CONFIG_PERMISSIONS.READ
|
|
1090
|
+
]
|
|
1091
|
+
},
|
|
1092
|
+
getAll: {
|
|
1093
|
+
level: 'permission',
|
|
1094
|
+
permissions: [
|
|
1095
|
+
constants_.SOCIAL_AUTH_CONFIG_PERMISSIONS.READ
|
|
1096
|
+
]
|
|
1097
|
+
},
|
|
1098
|
+
update: {
|
|
1099
|
+
level: 'permission',
|
|
1100
|
+
permissions: [
|
|
1101
|
+
constants_.SOCIAL_AUTH_CONFIG_PERMISSIONS.UPDATE
|
|
1102
|
+
]
|
|
1103
|
+
},
|
|
1104
|
+
delete: {
|
|
1105
|
+
level: 'permission',
|
|
1106
|
+
permissions: [
|
|
1107
|
+
constants_.SOCIAL_AUTH_CONFIG_PERMISSIONS.DELETE
|
|
1108
|
+
]
|
|
1109
|
+
}
|
|
1110
|
+
},
|
|
1111
|
+
enabledEndpoints: [
|
|
1112
|
+
'insert',
|
|
1113
|
+
'bulkUpsert',
|
|
1114
|
+
'getById',
|
|
1115
|
+
'getAll',
|
|
1116
|
+
'update',
|
|
1117
|
+
'delete'
|
|
1118
|
+
]
|
|
1119
|
+
}) {
|
|
1120
|
+
socialAuthConfigService;
|
|
1121
|
+
constructor(socialAuthConfigService){
|
|
1122
|
+
super(socialAuthConfigService), this.socialAuthConfigService = socialAuthConfigService;
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
SocialAuthConfigController = social_auth_config_controller_ts_decorate([
|
|
1126
|
+
(0,swagger_.ApiTags)('Social Auth Config'),
|
|
1127
|
+
(0,common_.Controller)('auth/social-config'),
|
|
1128
|
+
social_auth_config_controller_ts_param(0, (0,common_.Inject)(social_auth_config_service/* .SocialAuthConfigService */.t)),
|
|
1129
|
+
social_auth_config_controller_ts_metadata("design:type", Function),
|
|
1130
|
+
social_auth_config_controller_ts_metadata("design:paramtypes", [
|
|
1131
|
+
typeof social_auth_config_service/* .SocialAuthConfigService */.t === "undefined" ? Object : social_auth_config_service/* .SocialAuthConfigService */.t
|
|
1132
|
+
])
|
|
1133
|
+
], SocialAuthConfigController);
|
|
1134
|
+
|
|
1135
|
+
// EXTERNAL MODULE: external "class-transformer"
|
|
1136
|
+
var external_class_transformer_ = __webpack_require__(5812);
|
|
1137
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/dtos/user.dto.ts
|
|
1138
|
+
var user_dto = __webpack_require__(7265);
|
|
1139
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/services/user.service.ts
|
|
1140
|
+
var user_service = __webpack_require__(7229);
|
|
1141
|
+
;// CONCATENATED MODULE: ./projects/nestjs-auth/src/controllers/user.controller.ts
|
|
1142
|
+
function user_controller_ts_decorate(decorators, target, key, desc) {
|
|
1143
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1144
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1145
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1146
|
+
} else {
|
|
1147
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
1148
|
+
if (d = decorators[i]) {
|
|
1149
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1154
|
+
}
|
|
1155
|
+
function user_controller_ts_metadata(metadataKey, metadataValue) {
|
|
1156
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1157
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
function user_controller_ts_param(paramIndex, decorator) {
|
|
1161
|
+
return function(target, key) {
|
|
1162
|
+
decorator(target, key, paramIndex);
|
|
1163
|
+
};
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
|
|
1167
|
+
|
|
1168
|
+
|
|
1169
|
+
|
|
1170
|
+
|
|
1171
|
+
|
|
1172
|
+
|
|
1173
|
+
|
|
1174
|
+
|
|
1175
|
+
class UserController extends (0,classes_.createApiController)(user_dto/* .CreateUserDto */.TG, user_dto/* .UpdateUserDto */.Qf, user_dto/* .UserResponseDto */.kq, {
|
|
1176
|
+
entityName: 'user',
|
|
1177
|
+
security: {
|
|
1178
|
+
insert: {
|
|
1179
|
+
level: 'permission',
|
|
1180
|
+
permissions: [
|
|
1181
|
+
classes_.USER_PERMISSIONS.CREATE
|
|
1182
|
+
]
|
|
1183
|
+
},
|
|
1184
|
+
insertMany: {
|
|
1185
|
+
level: 'permission',
|
|
1186
|
+
permissions: [
|
|
1187
|
+
classes_.USER_PERMISSIONS.CREATE
|
|
1188
|
+
]
|
|
1189
|
+
},
|
|
1190
|
+
getById: {
|
|
1191
|
+
level: 'permission',
|
|
1192
|
+
permissions: [
|
|
1193
|
+
classes_.USER_PERMISSIONS.READ
|
|
1194
|
+
]
|
|
1195
|
+
},
|
|
1196
|
+
getAll: {
|
|
1197
|
+
level: 'permission',
|
|
1198
|
+
permissions: [
|
|
1199
|
+
classes_.USER_PERMISSIONS.READ
|
|
1200
|
+
]
|
|
1201
|
+
},
|
|
1202
|
+
update: {
|
|
1203
|
+
level: 'permission',
|
|
1204
|
+
permissions: [
|
|
1205
|
+
classes_.USER_PERMISSIONS.UPDATE
|
|
1206
|
+
]
|
|
1207
|
+
},
|
|
1208
|
+
updateMany: {
|
|
1209
|
+
level: 'permission',
|
|
1210
|
+
permissions: [
|
|
1211
|
+
classes_.USER_PERMISSIONS.UPDATE
|
|
1212
|
+
]
|
|
1213
|
+
},
|
|
1214
|
+
delete: {
|
|
1215
|
+
level: 'permission',
|
|
1216
|
+
permissions: [
|
|
1217
|
+
classes_.USER_PERMISSIONS.DELETE
|
|
1218
|
+
]
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
}) {
|
|
1222
|
+
service;
|
|
1223
|
+
constructor(service){
|
|
1224
|
+
super(service), this.service = service;
|
|
1225
|
+
}
|
|
1226
|
+
async lookup(filterAndPaginationDto, user, search) {
|
|
1227
|
+
const result = await this.service.getAll(search ?? '', filterAndPaginationDto, user);
|
|
1228
|
+
const data = result.data.map((item)=>(0,external_class_transformer_.plainToInstance)(user_dto/* .UserLookupResponseDto */.sx, item, {
|
|
1229
|
+
excludeExtraneousValues: true
|
|
1230
|
+
}));
|
|
1231
|
+
const page = filterAndPaginationDto.pagination?.currentPage ?? 0;
|
|
1232
|
+
const pageSize = filterAndPaginationDto.pagination?.pageSize ?? data.length;
|
|
1233
|
+
const totalPages = pageSize > 0 ? Math.ceil(result.total / pageSize) : 1;
|
|
1234
|
+
return {
|
|
1235
|
+
success: true,
|
|
1236
|
+
message: 'Users retrieved successfully',
|
|
1237
|
+
messageKey: message_keys/* .USER_MESSAGES.LOOKUP_SUCCESS */.ny.LOOKUP_SUCCESS,
|
|
1238
|
+
data,
|
|
1239
|
+
meta: {
|
|
1240
|
+
total: result.total,
|
|
1241
|
+
page,
|
|
1242
|
+
pageSize,
|
|
1243
|
+
count: data.length,
|
|
1244
|
+
hasMore: page < totalPages - 1,
|
|
1245
|
+
totalPages
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1248
|
+
}
|
|
1249
|
+
async getProfileWithExtras(id, user) {
|
|
1250
|
+
const data = await this.service.getProfileWithExtras(id, user);
|
|
1251
|
+
return {
|
|
1252
|
+
success: true,
|
|
1253
|
+
message: 'Profile extras retrieved successfully',
|
|
1254
|
+
messageKey: message_keys/* .USER_MESSAGES.PROFILE_EXTRAS_SUCCESS */.ny.PROFILE_EXTRAS_SUCCESS,
|
|
1255
|
+
data
|
|
1256
|
+
};
|
|
1257
|
+
}
|
|
1258
|
+
async verifyEmail(id) {
|
|
1259
|
+
await this.service.verifyEmail(id);
|
|
1260
|
+
return {
|
|
1261
|
+
success: true,
|
|
1262
|
+
message: 'Email verified successfully',
|
|
1263
|
+
messageKey: message_keys/* .USER_MESSAGES.EMAIL_VERIFY_SUCCESS */.ny.EMAIL_VERIFY_SUCCESS
|
|
1264
|
+
};
|
|
1265
|
+
}
|
|
1266
|
+
async verifyPhone(id) {
|
|
1267
|
+
await this.service.verifyPhone(id);
|
|
1268
|
+
return {
|
|
1269
|
+
success: true,
|
|
1270
|
+
message: 'Phone verified successfully',
|
|
1271
|
+
messageKey: message_keys/* .USER_MESSAGES.PHONE_VERIFY_SUCCESS */.ny.PHONE_VERIFY_SUCCESS
|
|
1272
|
+
};
|
|
1273
|
+
}
|
|
1274
|
+
async updateStatus(id, isActive, user) {
|
|
1275
|
+
await this.service.updateStatus(id, isActive, user);
|
|
1276
|
+
return {
|
|
1277
|
+
success: true,
|
|
1278
|
+
message: 'Status updated successfully',
|
|
1279
|
+
messageKey: message_keys/* .USER_MESSAGES.STATUS_UPDATE_SUCCESS */.ny.STATUS_UPDATE_SUCCESS
|
|
1280
|
+
};
|
|
1281
|
+
}
|
|
1282
|
+
async profile(dto, user) {
|
|
1283
|
+
const data = await this.service.profile(dto, user);
|
|
1284
|
+
return {
|
|
1285
|
+
success: true,
|
|
1286
|
+
message: 'Profile updated successfully',
|
|
1287
|
+
messageKey: message_keys/* .USER_MESSAGES.PROFILE_UPDATE_SUCCESS */.ny.PROFILE_UPDATE_SUCCESS,
|
|
1288
|
+
data
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1291
|
+
async getProfileSections() {
|
|
1292
|
+
const sections = await this.service.getProfileSections();
|
|
1293
|
+
return {
|
|
1294
|
+
success: true,
|
|
1295
|
+
message: 'Profile sections retrieved successfully',
|
|
1296
|
+
messageKey: message_keys/* .USER_MESSAGES.PROFILE_SECTIONS_SUCCESS */.ny.PROFILE_SECTIONS_SUCCESS,
|
|
1297
|
+
data: sections
|
|
1298
|
+
};
|
|
1299
|
+
}
|
|
1300
|
+
async getProfileSectionData(id, sectionId, user) {
|
|
1301
|
+
const data = await this.service.getProfileSectionData(id, sectionId, user);
|
|
1302
|
+
return {
|
|
1303
|
+
success: true,
|
|
1304
|
+
message: 'Profile section data retrieved successfully',
|
|
1305
|
+
messageKey: message_keys/* .USER_MESSAGES.PROFILE_SECTION_DATA_SUCCESS */.ny.PROFILE_SECTION_DATA_SUCCESS,
|
|
1306
|
+
data
|
|
1307
|
+
};
|
|
1308
|
+
}
|
|
1309
|
+
async updateProfileSection(id, sectionId, data, user) {
|
|
1310
|
+
await this.service.updateProfileSection(id, sectionId, data, user);
|
|
1311
|
+
return {
|
|
1312
|
+
success: true,
|
|
1313
|
+
message: 'Section updated successfully',
|
|
1314
|
+
messageKey: message_keys/* .USER_MESSAGES.PROFILE_SECTION_UPDATE_SUCCESS */.ny.PROFILE_SECTION_UPDATE_SUCCESS
|
|
1315
|
+
};
|
|
1316
|
+
}
|
|
1317
|
+
async getProfileCompletion(id, user) {
|
|
1318
|
+
const percentage = await this.service.getProfileCompletion(id, user);
|
|
1319
|
+
return {
|
|
1320
|
+
success: true,
|
|
1321
|
+
message: 'Profile completion retrieved successfully',
|
|
1322
|
+
messageKey: message_keys/* .USER_MESSAGES.PROFILE_COMPLETION_SUCCESS */.ny.PROFILE_COMPLETION_SUCCESS,
|
|
1323
|
+
data: {
|
|
1324
|
+
completionPercentage: percentage
|
|
1325
|
+
}
|
|
1326
|
+
};
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
user_controller_ts_decorate([
|
|
1330
|
+
(0,common_.Post)('lookup'),
|
|
1331
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
|
|
1332
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
1333
|
+
(0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequireAnyPermission)(classes_.USER_PERMISSIONS.READ, classes_.USER_PERMISSIONS.LOOKUP),
|
|
1334
|
+
(0,swagger_.ApiOperation)({
|
|
1335
|
+
summary: 'Lookup users for pickers/directory',
|
|
1336
|
+
description: 'Lightweight user directory search for selection widgets (event participants, assignees, etc.). ' + 'Returns only id/name/email. Accessible with USER_PERMISSIONS.READ or the narrower USER_PERMISSIONS.LOOKUP, ' + 'so panels that only need to pick a user do not require full user-management access.'
|
|
1337
|
+
}),
|
|
1338
|
+
(0,swagger_.ApiQuery)({
|
|
1339
|
+
name: 'q',
|
|
1340
|
+
required: false,
|
|
1341
|
+
description: 'Global text search across searchable fields'
|
|
1342
|
+
}),
|
|
1343
|
+
(0,swagger_.ApiBody)({
|
|
1344
|
+
type: dtos_.FilterAndPaginationDto
|
|
1345
|
+
}),
|
|
1346
|
+
user_controller_ts_param(0, (0,common_.Body)()),
|
|
1347
|
+
user_controller_ts_param(1, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)()),
|
|
1348
|
+
user_controller_ts_param(2, (0,common_.Query)('q')),
|
|
1349
|
+
user_controller_ts_metadata("design:type", Function),
|
|
1350
|
+
user_controller_ts_metadata("design:paramtypes", [
|
|
1351
|
+
typeof dtos_.FilterAndPaginationDto === "undefined" ? Object : dtos_.FilterAndPaginationDto,
|
|
1352
|
+
typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo,
|
|
1353
|
+
String
|
|
1354
|
+
]),
|
|
1355
|
+
user_controller_ts_metadata("design:returntype", Promise)
|
|
1356
|
+
], UserController.prototype, "lookup", null);
|
|
1357
|
+
user_controller_ts_decorate([
|
|
1358
|
+
(0,common_.Post)(':id/profile-extras'),
|
|
1359
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
|
|
1360
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
1361
|
+
(0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(classes_.USER_PERMISSIONS.READ),
|
|
1362
|
+
(0,swagger_.ApiOperation)({
|
|
1363
|
+
summary: 'Get user profile with extras',
|
|
1364
|
+
description: 'Returns user profile along with extra data (roles, permissions, etc.) if UserEnricher is provided.'
|
|
1365
|
+
}),
|
|
1366
|
+
(0,swagger_.ApiParam)({
|
|
1367
|
+
name: 'id',
|
|
1368
|
+
description: 'User ID'
|
|
1369
|
+
}),
|
|
1370
|
+
user_controller_ts_param(0, (0,common_.Param)('id')),
|
|
1371
|
+
user_controller_ts_param(1, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)()),
|
|
1372
|
+
user_controller_ts_metadata("design:type", Function),
|
|
1373
|
+
user_controller_ts_metadata("design:paramtypes", [
|
|
1374
|
+
String,
|
|
1375
|
+
typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
|
|
1376
|
+
]),
|
|
1377
|
+
user_controller_ts_metadata("design:returntype", Promise)
|
|
1378
|
+
], UserController.prototype, "getProfileWithExtras", null);
|
|
1379
|
+
user_controller_ts_decorate([
|
|
1380
|
+
(0,common_.Post)(':id/verify-email'),
|
|
1381
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
|
|
1382
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
1383
|
+
(0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(classes_.USER_PERMISSIONS.UPDATE),
|
|
1384
|
+
(0,swagger_.ApiOperation)({
|
|
1385
|
+
summary: 'Verify user email'
|
|
1386
|
+
}),
|
|
1387
|
+
(0,swagger_.ApiParam)({
|
|
1388
|
+
name: 'id',
|
|
1389
|
+
description: 'User ID'
|
|
1390
|
+
}),
|
|
1391
|
+
user_controller_ts_param(0, (0,common_.Param)('id')),
|
|
1392
|
+
user_controller_ts_metadata("design:type", Function),
|
|
1393
|
+
user_controller_ts_metadata("design:paramtypes", [
|
|
1394
|
+
String
|
|
1395
|
+
]),
|
|
1396
|
+
user_controller_ts_metadata("design:returntype", Promise)
|
|
1397
|
+
], UserController.prototype, "verifyEmail", null);
|
|
1398
|
+
user_controller_ts_decorate([
|
|
1399
|
+
(0,common_.Post)(':id/verify-phone'),
|
|
1400
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
|
|
1401
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
1402
|
+
(0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(classes_.USER_PERMISSIONS.UPDATE),
|
|
1403
|
+
(0,swagger_.ApiOperation)({
|
|
1404
|
+
summary: 'Verify user phone'
|
|
1405
|
+
}),
|
|
1406
|
+
(0,swagger_.ApiParam)({
|
|
1407
|
+
name: 'id',
|
|
1408
|
+
description: 'User ID'
|
|
1409
|
+
}),
|
|
1410
|
+
user_controller_ts_param(0, (0,common_.Param)('id')),
|
|
1411
|
+
user_controller_ts_metadata("design:type", Function),
|
|
1412
|
+
user_controller_ts_metadata("design:paramtypes", [
|
|
1413
|
+
String
|
|
1414
|
+
]),
|
|
1415
|
+
user_controller_ts_metadata("design:returntype", Promise)
|
|
1416
|
+
], UserController.prototype, "verifyPhone", null);
|
|
1417
|
+
user_controller_ts_decorate([
|
|
1418
|
+
(0,common_.Post)(':id/status'),
|
|
1419
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
|
|
1420
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
1421
|
+
(0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(classes_.USER_PERMISSIONS.UPDATE),
|
|
1422
|
+
(0,swagger_.ApiOperation)({
|
|
1423
|
+
summary: 'Update user active status',
|
|
1424
|
+
description: 'Updates user active status. When company feature is enabled, updates the status for the current company context.'
|
|
1425
|
+
}),
|
|
1426
|
+
(0,swagger_.ApiParam)({
|
|
1427
|
+
name: 'id',
|
|
1428
|
+
description: 'User ID'
|
|
1429
|
+
}),
|
|
1430
|
+
(0,swagger_.ApiBody)({
|
|
1431
|
+
schema: {
|
|
1432
|
+
example: {
|
|
1433
|
+
isActive: true
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
}),
|
|
1437
|
+
user_controller_ts_param(0, (0,common_.Param)('id')),
|
|
1438
|
+
user_controller_ts_param(1, (0,common_.Body)('isActive')),
|
|
1439
|
+
user_controller_ts_param(2, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)()),
|
|
1440
|
+
user_controller_ts_metadata("design:type", Function),
|
|
1441
|
+
user_controller_ts_metadata("design:paramtypes", [
|
|
1442
|
+
String,
|
|
1443
|
+
Boolean,
|
|
1444
|
+
typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
|
|
1445
|
+
]),
|
|
1446
|
+
user_controller_ts_metadata("design:returntype", Promise)
|
|
1447
|
+
], UserController.prototype, "updateStatus", null);
|
|
1448
|
+
user_controller_ts_decorate([
|
|
1449
|
+
(0,common_.Post)('profile'),
|
|
1450
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard),
|
|
1451
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
1452
|
+
(0,swagger_.ApiOperation)({
|
|
1453
|
+
summary: 'Update user profile'
|
|
1454
|
+
}),
|
|
1455
|
+
(0,swagger_.ApiBody)({
|
|
1456
|
+
type: user_dto/* .UpdateUserDto */.Qf
|
|
1457
|
+
}),
|
|
1458
|
+
user_controller_ts_param(0, (0,common_.Body)()),
|
|
1459
|
+
user_controller_ts_param(1, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)()),
|
|
1460
|
+
user_controller_ts_metadata("design:type", Function),
|
|
1461
|
+
user_controller_ts_metadata("design:paramtypes", [
|
|
1462
|
+
typeof user_dto/* .UpdateUserDto */.Qf === "undefined" ? Object : user_dto/* .UpdateUserDto */.Qf,
|
|
1463
|
+
typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
|
|
1464
|
+
]),
|
|
1465
|
+
user_controller_ts_metadata("design:returntype", Promise)
|
|
1466
|
+
], UserController.prototype, "profile", null);
|
|
1467
|
+
user_controller_ts_decorate([
|
|
1468
|
+
(0,common_.Post)('profile-sections'),
|
|
1469
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard),
|
|
1470
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
1471
|
+
(0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(classes_.USER_PERMISSIONS.READ),
|
|
1472
|
+
(0,swagger_.ApiOperation)({
|
|
1473
|
+
summary: 'Get profile section definitions',
|
|
1474
|
+
description: 'Returns available profile sections for multi-step profile (if enricher configured).'
|
|
1475
|
+
}),
|
|
1476
|
+
user_controller_ts_metadata("design:type", Function),
|
|
1477
|
+
user_controller_ts_metadata("design:paramtypes", []),
|
|
1478
|
+
user_controller_ts_metadata("design:returntype", Promise)
|
|
1479
|
+
], UserController.prototype, "getProfileSections", null);
|
|
1480
|
+
user_controller_ts_decorate([
|
|
1481
|
+
(0,common_.Post)(':id/profile-section/:sectionId'),
|
|
1482
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard),
|
|
1483
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
1484
|
+
(0,swagger_.ApiOperation)({
|
|
1485
|
+
summary: 'Get profile section data',
|
|
1486
|
+
description: 'Returns data for a specific profile section.'
|
|
1487
|
+
}),
|
|
1488
|
+
(0,swagger_.ApiParam)({
|
|
1489
|
+
name: 'id',
|
|
1490
|
+
description: 'User ID'
|
|
1491
|
+
}),
|
|
1492
|
+
(0,swagger_.ApiParam)({
|
|
1493
|
+
name: 'sectionId',
|
|
1494
|
+
description: 'Section identifier'
|
|
1495
|
+
}),
|
|
1496
|
+
user_controller_ts_param(0, (0,common_.Param)('id')),
|
|
1497
|
+
user_controller_ts_param(1, (0,common_.Param)('sectionId')),
|
|
1498
|
+
user_controller_ts_param(2, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)()),
|
|
1499
|
+
user_controller_ts_metadata("design:type", Function),
|
|
1500
|
+
user_controller_ts_metadata("design:paramtypes", [
|
|
1501
|
+
String,
|
|
1502
|
+
String,
|
|
1503
|
+
typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
|
|
1504
|
+
]),
|
|
1505
|
+
user_controller_ts_metadata("design:returntype", Promise)
|
|
1506
|
+
], UserController.prototype, "getProfileSectionData", null);
|
|
1507
|
+
user_controller_ts_decorate([
|
|
1508
|
+
(0,common_.Post)(':id/profile-section/:sectionId/update'),
|
|
1509
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard),
|
|
1510
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
1511
|
+
(0,swagger_.ApiOperation)({
|
|
1512
|
+
summary: 'Update profile section',
|
|
1513
|
+
description: 'Updates a specific profile section data.'
|
|
1514
|
+
}),
|
|
1515
|
+
(0,swagger_.ApiParam)({
|
|
1516
|
+
name: 'id',
|
|
1517
|
+
description: 'User ID'
|
|
1518
|
+
}),
|
|
1519
|
+
(0,swagger_.ApiParam)({
|
|
1520
|
+
name: 'sectionId',
|
|
1521
|
+
description: 'Section identifier'
|
|
1522
|
+
}),
|
|
1523
|
+
user_controller_ts_param(0, (0,common_.Param)('id')),
|
|
1524
|
+
user_controller_ts_param(1, (0,common_.Param)('sectionId')),
|
|
1525
|
+
user_controller_ts_param(2, (0,common_.Body)()),
|
|
1526
|
+
user_controller_ts_param(3, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)()),
|
|
1527
|
+
user_controller_ts_metadata("design:type", Function),
|
|
1528
|
+
user_controller_ts_metadata("design:paramtypes", [
|
|
1529
|
+
String,
|
|
1530
|
+
String,
|
|
1531
|
+
typeof Record === "undefined" ? Object : Record,
|
|
1532
|
+
typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
|
|
1533
|
+
]),
|
|
1534
|
+
user_controller_ts_metadata("design:returntype", Promise)
|
|
1535
|
+
], UserController.prototype, "updateProfileSection", null);
|
|
1536
|
+
user_controller_ts_decorate([
|
|
1537
|
+
(0,common_.Post)(':id/profile-completion'),
|
|
1538
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard),
|
|
1539
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
1540
|
+
(0,swagger_.ApiOperation)({
|
|
1541
|
+
summary: 'Get profile completion percentage',
|
|
1542
|
+
description: 'Returns overall profile completion percentage.'
|
|
1543
|
+
}),
|
|
1544
|
+
(0,swagger_.ApiParam)({
|
|
1545
|
+
name: 'id',
|
|
1546
|
+
description: 'User ID'
|
|
1547
|
+
}),
|
|
1548
|
+
user_controller_ts_param(0, (0,common_.Param)('id')),
|
|
1549
|
+
user_controller_ts_param(1, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)()),
|
|
1550
|
+
user_controller_ts_metadata("design:type", Function),
|
|
1551
|
+
user_controller_ts_metadata("design:paramtypes", [
|
|
1552
|
+
String,
|
|
1553
|
+
typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
|
|
1554
|
+
]),
|
|
1555
|
+
user_controller_ts_metadata("design:returntype", Promise)
|
|
1556
|
+
], UserController.prototype, "getProfileCompletion", null);
|
|
1557
|
+
UserController = user_controller_ts_decorate([
|
|
1558
|
+
(0,swagger_.ApiTags)('Users'),
|
|
1559
|
+
(0,common_.Controller)('administration/users'),
|
|
1560
|
+
user_controller_ts_param(0, (0,common_.Inject)(user_service/* .UserService */.D)),
|
|
1561
|
+
user_controller_ts_metadata("design:type", Function),
|
|
1562
|
+
user_controller_ts_metadata("design:paramtypes", [
|
|
1563
|
+
typeof user_service/* .UserService */.D === "undefined" ? Object : user_service/* .UserService */.D
|
|
1564
|
+
])
|
|
1565
|
+
], UserController);
|
|
1566
|
+
|
|
1567
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/dtos/company.dto.ts
|
|
1568
|
+
var company_dto = __webpack_require__(1845);
|
|
1569
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/services/company.service.ts
|
|
1570
|
+
var company_service = __webpack_require__(9201);
|
|
1571
|
+
;// CONCATENATED MODULE: ./projects/nestjs-auth/src/controllers/company.controller.ts
|
|
1572
|
+
function company_controller_ts_decorate(decorators, target, key, desc) {
|
|
1573
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1574
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1575
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1576
|
+
} else {
|
|
1577
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
1578
|
+
if (d = decorators[i]) {
|
|
1579
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1584
|
+
}
|
|
1585
|
+
function company_controller_ts_metadata(metadataKey, metadataValue) {
|
|
1586
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1587
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
function company_controller_ts_param(paramIndex, decorator) {
|
|
1591
|
+
return function(target, key) {
|
|
1592
|
+
decorator(target, key, paramIndex);
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
|
|
1597
|
+
|
|
1598
|
+
|
|
1599
|
+
|
|
1600
|
+
class CompanyController extends (0,classes_.createApiController)(company_dto/* .CreateCompanyDto */.l4, company_dto/* .UpdateCompanyDto */.Ky, company_dto/* .CompanyResponseDto */.cd, {
|
|
1601
|
+
entityName: 'company',
|
|
1602
|
+
security: {
|
|
1603
|
+
insert: {
|
|
1604
|
+
level: 'permission',
|
|
1605
|
+
permissions: [
|
|
1606
|
+
classes_.COMPANY_PERMISSIONS.CREATE
|
|
1607
|
+
]
|
|
1608
|
+
},
|
|
1609
|
+
insertMany: {
|
|
1610
|
+
level: 'permission',
|
|
1611
|
+
permissions: [
|
|
1612
|
+
classes_.COMPANY_PERMISSIONS.CREATE
|
|
1613
|
+
]
|
|
1614
|
+
},
|
|
1615
|
+
getById: {
|
|
1616
|
+
level: 'permission',
|
|
1617
|
+
permissions: [
|
|
1618
|
+
classes_.COMPANY_PERMISSIONS.READ
|
|
1619
|
+
]
|
|
1620
|
+
},
|
|
1621
|
+
getAll: {
|
|
1622
|
+
level: 'permission',
|
|
1623
|
+
permissions: [
|
|
1624
|
+
classes_.COMPANY_PERMISSIONS.READ
|
|
1625
|
+
]
|
|
1626
|
+
},
|
|
1627
|
+
update: {
|
|
1628
|
+
level: 'permission',
|
|
1629
|
+
permissions: [
|
|
1630
|
+
classes_.COMPANY_PERMISSIONS.UPDATE
|
|
1631
|
+
]
|
|
1632
|
+
},
|
|
1633
|
+
updateMany: {
|
|
1634
|
+
level: 'permission',
|
|
1635
|
+
permissions: [
|
|
1636
|
+
classes_.COMPANY_PERMISSIONS.UPDATE
|
|
1637
|
+
]
|
|
1638
|
+
},
|
|
1639
|
+
delete: {
|
|
1640
|
+
level: 'permission',
|
|
1641
|
+
permissions: [
|
|
1642
|
+
classes_.COMPANY_PERMISSIONS.DELETE
|
|
1643
|
+
]
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
}) {
|
|
1647
|
+
companyService;
|
|
1648
|
+
constructor(companyService){
|
|
1649
|
+
super(companyService), this.companyService = companyService;
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
CompanyController = company_controller_ts_decorate([
|
|
1653
|
+
(0,swagger_.ApiTags)('Companies'),
|
|
1654
|
+
(0,common_.Controller)('administration/company'),
|
|
1655
|
+
company_controller_ts_param(0, (0,common_.Inject)(company_service/* .CompanyService */.B)),
|
|
1656
|
+
company_controller_ts_metadata("design:type", Function),
|
|
1657
|
+
company_controller_ts_metadata("design:paramtypes", [
|
|
1658
|
+
typeof company_service/* .CompanyService */.B === "undefined" ? Object : company_service/* .CompanyService */.B
|
|
1659
|
+
])
|
|
1660
|
+
], CompanyController);
|
|
1661
|
+
|
|
1662
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/dtos/company-branch.dto.ts
|
|
1663
|
+
var company_branch_dto = __webpack_require__(9556);
|
|
1664
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/services/branch.service.ts
|
|
1665
|
+
var branch_service = __webpack_require__(5402);
|
|
1666
|
+
;// CONCATENATED MODULE: ./projects/nestjs-auth/src/controllers/branch.controller.ts
|
|
1667
|
+
function branch_controller_ts_decorate(decorators, target, key, desc) {
|
|
1668
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1669
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1670
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1671
|
+
} else {
|
|
1672
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
1673
|
+
if (d = decorators[i]) {
|
|
1674
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1679
|
+
}
|
|
1680
|
+
function branch_controller_ts_metadata(metadataKey, metadataValue) {
|
|
1681
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1682
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
function branch_controller_ts_param(paramIndex, decorator) {
|
|
1686
|
+
return function(target, key) {
|
|
1687
|
+
decorator(target, key, paramIndex);
|
|
1688
|
+
};
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
|
|
1692
|
+
|
|
1693
|
+
|
|
1694
|
+
|
|
1695
|
+
class BranchController extends (0,classes_.createApiController)(company_branch_dto/* .CreateCompanyBranchDto */.Vw, company_branch_dto/* .UpdateCompanyBranchDto */.Oo, company_branch_dto/* .CompanyBranchResponseDto */.ET, {
|
|
1696
|
+
entityName: 'branch',
|
|
1697
|
+
security: {
|
|
1698
|
+
insert: {
|
|
1699
|
+
level: 'permission',
|
|
1700
|
+
permissions: [
|
|
1701
|
+
classes_.BRANCH_PERMISSIONS.CREATE
|
|
1702
|
+
]
|
|
1703
|
+
},
|
|
1704
|
+
insertMany: {
|
|
1705
|
+
level: 'permission',
|
|
1706
|
+
permissions: [
|
|
1707
|
+
classes_.BRANCH_PERMISSIONS.CREATE
|
|
1708
|
+
]
|
|
1709
|
+
},
|
|
1710
|
+
getById: {
|
|
1711
|
+
level: 'permission',
|
|
1712
|
+
permissions: [
|
|
1713
|
+
classes_.BRANCH_PERMISSIONS.READ
|
|
1714
|
+
]
|
|
1715
|
+
},
|
|
1716
|
+
getAll: {
|
|
1717
|
+
level: 'permission',
|
|
1718
|
+
permissions: [
|
|
1719
|
+
classes_.BRANCH_PERMISSIONS.READ
|
|
1720
|
+
]
|
|
1721
|
+
},
|
|
1722
|
+
update: {
|
|
1723
|
+
level: 'permission',
|
|
1724
|
+
permissions: [
|
|
1725
|
+
classes_.BRANCH_PERMISSIONS.UPDATE
|
|
1726
|
+
]
|
|
1727
|
+
},
|
|
1728
|
+
updateMany: {
|
|
1729
|
+
level: 'permission',
|
|
1730
|
+
permissions: [
|
|
1731
|
+
classes_.BRANCH_PERMISSIONS.UPDATE
|
|
1732
|
+
]
|
|
1733
|
+
},
|
|
1734
|
+
delete: {
|
|
1735
|
+
level: 'permission',
|
|
1736
|
+
permissions: [
|
|
1737
|
+
classes_.BRANCH_PERMISSIONS.DELETE
|
|
1738
|
+
]
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
}) {
|
|
1742
|
+
branchService;
|
|
1743
|
+
constructor(branchService){
|
|
1744
|
+
super(branchService), this.branchService = branchService;
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
BranchController = branch_controller_ts_decorate([
|
|
1748
|
+
(0,swagger_.ApiTags)('Branches'),
|
|
1749
|
+
(0,common_.Controller)('administration/branch'),
|
|
1750
|
+
branch_controller_ts_param(0, (0,common_.Inject)(branch_service/* .BranchService */.O)),
|
|
1751
|
+
branch_controller_ts_metadata("design:type", Function),
|
|
1752
|
+
branch_controller_ts_metadata("design:paramtypes", [
|
|
1753
|
+
typeof branch_service/* .BranchService */.O === "undefined" ? Object : branch_service/* .BranchService */.O
|
|
1754
|
+
])
|
|
1755
|
+
], BranchController);
|
|
1756
|
+
|
|
1757
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/dtos/user-permission.dto.ts
|
|
1758
|
+
var user_permission_dto = __webpack_require__(3939);
|
|
1759
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/entities/user-company-permission.entity.ts
|
|
1760
|
+
var user_company_permission_entity = __webpack_require__(2377);
|
|
1761
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/services/user-permission.service.ts
|
|
1762
|
+
var user_permission_service = __webpack_require__(5291);
|
|
1763
|
+
;// CONCATENATED MODULE: ./projects/nestjs-auth/src/controllers/user-permission.controller.ts
|
|
1764
|
+
function user_permission_controller_ts_decorate(decorators, target, key, desc) {
|
|
1765
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1766
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1767
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1768
|
+
} else {
|
|
1769
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
1770
|
+
if (d = decorators[i]) {
|
|
1771
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1776
|
+
}
|
|
1777
|
+
function user_permission_controller_ts_metadata(metadataKey, metadataValue) {
|
|
1778
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1779
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
function user_permission_controller_ts_param(paramIndex, decorator) {
|
|
1783
|
+
return function(target, key) {
|
|
1784
|
+
decorator(target, key, paramIndex);
|
|
1785
|
+
};
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
|
|
1789
|
+
|
|
1790
|
+
|
|
1791
|
+
|
|
1792
|
+
|
|
1793
|
+
|
|
1794
|
+
|
|
1795
|
+
class UserPermissionController {
|
|
1796
|
+
permissionService;
|
|
1797
|
+
constructor(permissionService){
|
|
1798
|
+
this.permissionService = permissionService;
|
|
1799
|
+
}
|
|
1800
|
+
async assignUserCompany(dto, user) {
|
|
1801
|
+
return this.processBatchPermissions(dto.userId, dto.items, user_company_permission_entity/* .PermissionType.COMPANY */.e.COMPANY, user);
|
|
1802
|
+
}
|
|
1803
|
+
async getUserCompanies(userId) {
|
|
1804
|
+
const permissions = await this.permissionService.findUserCompanies(userId);
|
|
1805
|
+
return {
|
|
1806
|
+
success: true,
|
|
1807
|
+
message: 'User companies retrieved successfully',
|
|
1808
|
+
messageKey: message_keys/* .USER_PERMISSION_MESSAGES.COMPANY_LIST_SUCCESS */.jz.COMPANY_LIST_SUCCESS,
|
|
1809
|
+
data: permissions.map((p)=>({
|
|
1810
|
+
id: p.id,
|
|
1811
|
+
userId: p.userId,
|
|
1812
|
+
companyId: p.company?.id || p.targetId,
|
|
1813
|
+
companyName: p.company?.name || '',
|
|
1814
|
+
companySlug: p.company?.slug || ''
|
|
1815
|
+
}))
|
|
1816
|
+
};
|
|
1817
|
+
}
|
|
1818
|
+
async assignUserBranch(dto, user) {
|
|
1819
|
+
return this.processBatchPermissions(dto.userId, dto.items, user_company_permission_entity/* .PermissionType.BRANCH */.e.BRANCH, user);
|
|
1820
|
+
}
|
|
1821
|
+
async getUserBranches(userId, companyId) {
|
|
1822
|
+
const permissions = await this.permissionService.findUserBranches(userId, companyId);
|
|
1823
|
+
return {
|
|
1824
|
+
success: true,
|
|
1825
|
+
message: 'User branches retrieved successfully',
|
|
1826
|
+
messageKey: message_keys/* .USER_PERMISSION_MESSAGES.BRANCH_LIST_SUCCESS */.jz.BRANCH_LIST_SUCCESS,
|
|
1827
|
+
data: permissions.map((p)=>({
|
|
1828
|
+
id: p.id,
|
|
1829
|
+
userId: p.userId,
|
|
1830
|
+
branchId: p.branch?.id || p.targetId,
|
|
1831
|
+
branchName: p.branch?.name || '',
|
|
1832
|
+
branchSlug: p.branch?.slug || '',
|
|
1833
|
+
companyId: p.branch?.companyId || ''
|
|
1834
|
+
}))
|
|
1835
|
+
};
|
|
1836
|
+
}
|
|
1837
|
+
async getCompanyUsers(dto) {
|
|
1838
|
+
const permissions = await this.permissionService.findUsersForCompany(dto.companyId);
|
|
1839
|
+
return {
|
|
1840
|
+
success: true,
|
|
1841
|
+
message: 'Company users retrieved successfully',
|
|
1842
|
+
messageKey: message_keys/* .USER_PERMISSION_MESSAGES.COMPANY_USERS_SUCCESS */.jz.COMPANY_USERS_SUCCESS,
|
|
1843
|
+
data: permissions.filter((p)=>!!p.user).map((p)=>({
|
|
1844
|
+
id: p.id,
|
|
1845
|
+
userId: p.userId,
|
|
1846
|
+
userName: p.user?.name || p.user?.email || '',
|
|
1847
|
+
userEmail: p.user?.email || ''
|
|
1848
|
+
}))
|
|
1849
|
+
};
|
|
1850
|
+
}
|
|
1851
|
+
async getBranchUsers(dto) {
|
|
1852
|
+
const permissions = await this.permissionService.findUsersForBranch(dto.branchId);
|
|
1853
|
+
return {
|
|
1854
|
+
success: true,
|
|
1855
|
+
message: 'Branch users retrieved successfully',
|
|
1856
|
+
messageKey: message_keys/* .USER_PERMISSION_MESSAGES.BRANCH_USERS_SUCCESS */.jz.BRANCH_USERS_SUCCESS,
|
|
1857
|
+
data: permissions.filter((p)=>!!p.user).map((p)=>({
|
|
1858
|
+
id: p.id,
|
|
1859
|
+
userId: p.userId,
|
|
1860
|
+
userName: p.user?.name || p.user?.email || '',
|
|
1861
|
+
userEmail: p.user?.email || ''
|
|
1862
|
+
}))
|
|
1863
|
+
};
|
|
1864
|
+
}
|
|
1865
|
+
/** Process batch permission assignments/revocations */ async processBatchPermissions(userId, items, type, user) {
|
|
1866
|
+
let added = 0, removed = 0;
|
|
1867
|
+
for (const item of items){
|
|
1868
|
+
await this.permissionService.validateTenantScope(type, item.targetId, user);
|
|
1869
|
+
if (item.isAdd) {
|
|
1870
|
+
await this.permissionService.assignPermission(userId, item.targetId, type);
|
|
1871
|
+
added++;
|
|
1872
|
+
} else {
|
|
1873
|
+
await this.permissionService.revokePermission(userId, item.targetId, type);
|
|
1874
|
+
removed++;
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
return {
|
|
1878
|
+
success: true,
|
|
1879
|
+
message: `Processed ${added} additions and ${removed} removals`,
|
|
1880
|
+
messageKey: message_keys/* .USER_PERMISSION_MESSAGES.BATCH_SUCCESS */.jz.BATCH_SUCCESS,
|
|
1881
|
+
messageVariables: {
|
|
1882
|
+
added,
|
|
1883
|
+
removed
|
|
1884
|
+
}
|
|
1885
|
+
};
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
user_permission_controller_ts_decorate([
|
|
1889
|
+
(0,common_.Post)('user-company/assign'),
|
|
1890
|
+
(0,nestjs_shared_.RequirePermission)(nestjs_shared_.USER_PERMISSIONS.UPDATE),
|
|
1891
|
+
(0,swagger_.ApiOperation)({
|
|
1892
|
+
summary: 'Batch assign/revoke user-company permissions'
|
|
1893
|
+
}),
|
|
1894
|
+
(0,swagger_.ApiResponse)({
|
|
1895
|
+
status: 200,
|
|
1896
|
+
description: 'Company permissions updated successfully'
|
|
1897
|
+
}),
|
|
1898
|
+
(0,swagger_.ApiBody)({
|
|
1899
|
+
type: user_permission_dto/* .AssignUserCompanyDto */.DU
|
|
1900
|
+
}),
|
|
1901
|
+
user_permission_controller_ts_param(0, (0,common_.Body)()),
|
|
1902
|
+
user_permission_controller_ts_param(1, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)()),
|
|
1903
|
+
user_permission_controller_ts_metadata("design:type", Function),
|
|
1904
|
+
user_permission_controller_ts_metadata("design:paramtypes", [
|
|
1905
|
+
typeof user_permission_dto/* .AssignUserCompanyDto */.DU === "undefined" ? Object : user_permission_dto/* .AssignUserCompanyDto */.DU,
|
|
1906
|
+
typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
|
|
1907
|
+
]),
|
|
1908
|
+
user_permission_controller_ts_metadata("design:returntype", Promise)
|
|
1909
|
+
], UserPermissionController.prototype, "assignUserCompany", null);
|
|
1910
|
+
user_permission_controller_ts_decorate([
|
|
1911
|
+
(0,common_.Post)('get-user-company'),
|
|
1912
|
+
(0,nestjs_shared_.RequirePermission)(nestjs_shared_.USER_PERMISSIONS.READ),
|
|
1913
|
+
(0,swagger_.ApiOperation)({
|
|
1914
|
+
summary: 'Get user companies'
|
|
1915
|
+
}),
|
|
1916
|
+
(0,swagger_.ApiBody)({
|
|
1917
|
+
schema: {
|
|
1918
|
+
properties: {
|
|
1919
|
+
userId: {
|
|
1920
|
+
type: 'string'
|
|
1921
|
+
}
|
|
1922
|
+
},
|
|
1923
|
+
required: [
|
|
1924
|
+
'userId'
|
|
1925
|
+
]
|
|
1926
|
+
}
|
|
1927
|
+
}),
|
|
1928
|
+
(0,swagger_.ApiResponse)({
|
|
1929
|
+
status: 200,
|
|
1930
|
+
type: user_permission_dto/* .UserCompaniesResponseDto */.LU
|
|
1931
|
+
}),
|
|
1932
|
+
user_permission_controller_ts_param(0, (0,common_.Body)('userId')),
|
|
1933
|
+
user_permission_controller_ts_metadata("design:type", Function),
|
|
1934
|
+
user_permission_controller_ts_metadata("design:paramtypes", [
|
|
1935
|
+
String
|
|
1936
|
+
]),
|
|
1937
|
+
user_permission_controller_ts_metadata("design:returntype", Promise)
|
|
1938
|
+
], UserPermissionController.prototype, "getUserCompanies", null);
|
|
1939
|
+
user_permission_controller_ts_decorate([
|
|
1940
|
+
(0,common_.Post)('user-branch/assign'),
|
|
1941
|
+
(0,nestjs_shared_.RequirePermission)(nestjs_shared_.USER_PERMISSIONS.UPDATE),
|
|
1942
|
+
(0,swagger_.ApiOperation)({
|
|
1943
|
+
summary: 'Batch assign/revoke user-branch permissions'
|
|
1944
|
+
}),
|
|
1945
|
+
(0,swagger_.ApiResponse)({
|
|
1946
|
+
status: 200,
|
|
1947
|
+
description: 'Branch permissions updated successfully'
|
|
1948
|
+
}),
|
|
1949
|
+
(0,swagger_.ApiBody)({
|
|
1950
|
+
type: user_permission_dto/* .AssignUserBranchDto */.qW
|
|
1951
|
+
}),
|
|
1952
|
+
user_permission_controller_ts_param(0, (0,common_.Body)()),
|
|
1953
|
+
user_permission_controller_ts_param(1, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)()),
|
|
1954
|
+
user_permission_controller_ts_metadata("design:type", Function),
|
|
1955
|
+
user_permission_controller_ts_metadata("design:paramtypes", [
|
|
1956
|
+
typeof user_permission_dto/* .AssignUserBranchDto */.qW === "undefined" ? Object : user_permission_dto/* .AssignUserBranchDto */.qW,
|
|
1957
|
+
typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
|
|
1958
|
+
]),
|
|
1959
|
+
user_permission_controller_ts_metadata("design:returntype", Promise)
|
|
1960
|
+
], UserPermissionController.prototype, "assignUserBranch", null);
|
|
1961
|
+
user_permission_controller_ts_decorate([
|
|
1962
|
+
(0,common_.Post)('get-user-branch'),
|
|
1963
|
+
(0,nestjs_shared_.RequirePermission)(nestjs_shared_.USER_PERMISSIONS.READ),
|
|
1964
|
+
(0,swagger_.ApiOperation)({
|
|
1965
|
+
summary: 'Get user branches'
|
|
1966
|
+
}),
|
|
1967
|
+
(0,swagger_.ApiBody)({
|
|
1968
|
+
schema: {
|
|
1969
|
+
properties: {
|
|
1970
|
+
userId: {
|
|
1971
|
+
type: 'string'
|
|
1972
|
+
},
|
|
1973
|
+
companyId: {
|
|
1974
|
+
type: 'string',
|
|
1975
|
+
description: 'Optional company ID to filter branches'
|
|
1976
|
+
}
|
|
1977
|
+
},
|
|
1978
|
+
required: [
|
|
1979
|
+
'userId'
|
|
1980
|
+
]
|
|
1981
|
+
}
|
|
1982
|
+
}),
|
|
1983
|
+
(0,swagger_.ApiResponse)({
|
|
1984
|
+
status: 200,
|
|
1985
|
+
type: user_permission_dto/* .UserBranchesResponseDto */.wc
|
|
1986
|
+
}),
|
|
1987
|
+
user_permission_controller_ts_param(0, (0,common_.Body)('userId')),
|
|
1988
|
+
user_permission_controller_ts_param(1, (0,common_.Body)('companyId')),
|
|
1989
|
+
user_permission_controller_ts_metadata("design:type", Function),
|
|
1990
|
+
user_permission_controller_ts_metadata("design:paramtypes", [
|
|
1991
|
+
String,
|
|
1992
|
+
String
|
|
1993
|
+
]),
|
|
1994
|
+
user_permission_controller_ts_metadata("design:returntype", Promise)
|
|
1995
|
+
], UserPermissionController.prototype, "getUserBranches", null);
|
|
1996
|
+
user_permission_controller_ts_decorate([
|
|
1997
|
+
(0,common_.Post)('get-company-users'),
|
|
1998
|
+
(0,nestjs_shared_.RequirePermission)(nestjs_shared_.USER_PERMISSIONS.READ),
|
|
1999
|
+
(0,swagger_.ApiOperation)({
|
|
2000
|
+
summary: 'Get users permitted for a company'
|
|
2001
|
+
}),
|
|
2002
|
+
(0,swagger_.ApiBody)({
|
|
2003
|
+
type: user_permission_dto/* .GetCompanyUsersDto */.xx
|
|
2004
|
+
}),
|
|
2005
|
+
(0,swagger_.ApiResponse)({
|
|
2006
|
+
status: 200,
|
|
2007
|
+
type: user_permission_dto/* .CompanyPermittedUsersResponseDto */.a
|
|
2008
|
+
}),
|
|
2009
|
+
user_permission_controller_ts_param(0, (0,common_.Body)()),
|
|
2010
|
+
user_permission_controller_ts_metadata("design:type", Function),
|
|
2011
|
+
user_permission_controller_ts_metadata("design:paramtypes", [
|
|
2012
|
+
typeof user_permission_dto/* .GetCompanyUsersDto */.xx === "undefined" ? Object : user_permission_dto/* .GetCompanyUsersDto */.xx
|
|
2013
|
+
]),
|
|
2014
|
+
user_permission_controller_ts_metadata("design:returntype", Promise)
|
|
2015
|
+
], UserPermissionController.prototype, "getCompanyUsers", null);
|
|
2016
|
+
user_permission_controller_ts_decorate([
|
|
2017
|
+
(0,common_.Post)('get-branch-users'),
|
|
2018
|
+
(0,nestjs_shared_.RequirePermission)(nestjs_shared_.USER_PERMISSIONS.READ),
|
|
2019
|
+
(0,swagger_.ApiOperation)({
|
|
2020
|
+
summary: 'Get users permitted for a branch'
|
|
2021
|
+
}),
|
|
2022
|
+
(0,swagger_.ApiBody)({
|
|
2023
|
+
type: user_permission_dto/* .GetBranchUsersDto */.GF
|
|
2024
|
+
}),
|
|
2025
|
+
(0,swagger_.ApiResponse)({
|
|
2026
|
+
status: 200,
|
|
2027
|
+
type: user_permission_dto/* .BranchPermittedUsersResponseDto */.bK
|
|
2028
|
+
}),
|
|
2029
|
+
user_permission_controller_ts_param(0, (0,common_.Body)()),
|
|
2030
|
+
user_permission_controller_ts_metadata("design:type", Function),
|
|
2031
|
+
user_permission_controller_ts_metadata("design:paramtypes", [
|
|
2032
|
+
typeof user_permission_dto/* .GetBranchUsersDto */.GF === "undefined" ? Object : user_permission_dto/* .GetBranchUsersDto */.GF
|
|
2033
|
+
]),
|
|
2034
|
+
user_permission_controller_ts_metadata("design:returntype", Promise)
|
|
2035
|
+
], UserPermissionController.prototype, "getBranchUsers", null);
|
|
2036
|
+
UserPermissionController = user_permission_controller_ts_decorate([
|
|
2037
|
+
(0,swagger_.ApiTags)('User Permissions'),
|
|
2038
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
2039
|
+
(0,common_.Controller)('administration/permissions'),
|
|
2040
|
+
(0,common_.UseGuards)(nestjs_shared_.JwtAuthGuard, nestjs_shared_.PermissionGuard),
|
|
2041
|
+
user_permission_controller_ts_param(0, (0,common_.Inject)(user_permission_service/* .UserPermissionService */.O)),
|
|
2042
|
+
user_permission_controller_ts_metadata("design:type", Function),
|
|
2043
|
+
user_permission_controller_ts_metadata("design:paramtypes", [
|
|
2044
|
+
typeof user_permission_service/* .UserPermissionService */.O === "undefined" ? Object : user_permission_service/* .UserPermissionService */.O
|
|
2045
|
+
])
|
|
2046
|
+
], UserPermissionController);
|
|
2047
|
+
|
|
2048
|
+
;// CONCATENATED MODULE: ./projects/nestjs-auth/src/controllers/index.ts
|
|
2049
|
+
|
|
2050
|
+
|
|
2051
|
+
|
|
2052
|
+
|
|
2053
|
+
|
|
2054
|
+
|
|
2055
|
+
|
|
2056
|
+
|
|
2057
|
+
|
|
2058
|
+
|
|
2059
|
+
|
|
2060
|
+
},
|
|
2061
|
+
5207(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
2062
|
+
/* import */ var _flusys_nestjs_shared_utils__rspack_import_0 = __webpack_require__(9216);
|
|
2063
|
+
/* import */ var _nestjs_common__rspack_import_1 = __webpack_require__(6157);
|
|
2064
|
+
/* import */ var rxjs__rspack_import_2 = __webpack_require__(7271);
|
|
2065
|
+
/* import */ var _config_index_js__rspack_import_4 = __webpack_require__(5588);
|
|
2066
|
+
/* import */ var _services_auth_config_service_js__rspack_import_3 = __webpack_require__(6514);
|
|
2067
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
2068
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2069
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2070
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2071
|
+
} else {
|
|
2072
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
2073
|
+
if (d = decorators[i]) {
|
|
2074
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2079
|
+
}
|
|
2080
|
+
function _ts_metadata(metadataKey, metadataValue) {
|
|
2081
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2082
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
function _ts_param(paramIndex, decorator) {
|
|
2086
|
+
return function(target, key) {
|
|
2087
|
+
decorator(target, key, paramIndex);
|
|
2088
|
+
};
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
|
|
2092
|
+
|
|
2093
|
+
|
|
2094
|
+
|
|
2095
|
+
class ClearToken {
|
|
2096
|
+
authConfig;
|
|
2097
|
+
constructor(authConfig){
|
|
2098
|
+
this.authConfig = authConfig;
|
|
2099
|
+
}
|
|
2100
|
+
get cookieName() {
|
|
2101
|
+
return this.authConfig?.getRefreshTokenCookieName() ?? _config_index_js__rspack_import_4/* .DEFAULT_COOKIE_NAME */.rv;
|
|
2102
|
+
}
|
|
2103
|
+
intercept(context, next) {
|
|
2104
|
+
const req = context.switchToHttp().getRequest();
|
|
2105
|
+
const res = context.switchToHttp().getResponse();
|
|
2106
|
+
return next.handle().pipe((0,rxjs__rspack_import_2.map)((value)=>{
|
|
2107
|
+
if ((0,_flusys_nestjs_shared_utils__rspack_import_0.isBrowserRequest)(req)) {
|
|
2108
|
+
res.clearCookie(this.cookieName, {
|
|
2109
|
+
httpOnly: true,
|
|
2110
|
+
path: '/',
|
|
2111
|
+
...(0,_flusys_nestjs_shared_utils__rspack_import_0.buildCookieOptions)(req)
|
|
2112
|
+
});
|
|
2113
|
+
}
|
|
2114
|
+
return value;
|
|
2115
|
+
}));
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
ClearToken = _ts_decorate([
|
|
2119
|
+
(0,_nestjs_common__rspack_import_1.Injectable)(),
|
|
2120
|
+
_ts_param(0, (0,_nestjs_common__rspack_import_1.Optional)()),
|
|
2121
|
+
_ts_metadata("design:type", Function),
|
|
2122
|
+
_ts_metadata("design:paramtypes", [
|
|
2123
|
+
typeof _services_auth_config_service_js__rspack_import_3/* .AuthConfigService */.W === "undefined" ? Object : _services_auth_config_service_js__rspack_import_3/* .AuthConfigService */.W
|
|
2124
|
+
])
|
|
2125
|
+
], ClearToken);
|
|
2126
|
+
|
|
2127
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
2128
|
+
t: () => (ClearToken)
|
|
2129
|
+
});
|
|
2130
|
+
|
|
2131
|
+
|
|
2132
|
+
},
|
|
2133
|
+
8359(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
2134
|
+
|
|
2135
|
+
// EXPORTS
|
|
2136
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
2137
|
+
A: () => (/* binding */ SetToken)
|
|
2138
|
+
});
|
|
2139
|
+
|
|
2140
|
+
// EXTERNAL MODULE: external "@flusys/nestjs-shared/utils"
|
|
2141
|
+
var utils_ = __webpack_require__(9216);
|
|
2142
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/config/message-keys.ts
|
|
2143
|
+
var message_keys = __webpack_require__(5363);
|
|
2144
|
+
// EXTERNAL MODULE: external "@nestjs/common"
|
|
2145
|
+
var common_ = __webpack_require__(6157);
|
|
2146
|
+
;// CONCATENATED MODULE: external "buffer"
|
|
2147
|
+
|
|
2148
|
+
// EXTERNAL MODULE: external "rxjs"
|
|
2149
|
+
var external_rxjs_ = __webpack_require__(7271);
|
|
2150
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/config/auth.constants.ts
|
|
2151
|
+
var auth_constants = __webpack_require__(5588);
|
|
2152
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/services/auth-config.service.ts + 1 modules
|
|
2153
|
+
var auth_config_service = __webpack_require__(6514);
|
|
2154
|
+
;// CONCATENATED MODULE: ./projects/nestjs-auth/src/interceptors/set-token.interceptor.ts
|
|
2155
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
2156
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2157
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2158
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2159
|
+
} else {
|
|
2160
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
2161
|
+
if (d = decorators[i]) {
|
|
2162
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2167
|
+
}
|
|
2168
|
+
function _ts_metadata(metadataKey, metadataValue) {
|
|
2169
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2170
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
function _ts_param(paramIndex, decorator) {
|
|
2174
|
+
return function(target, key) {
|
|
2175
|
+
decorator(target, key, paramIndex);
|
|
2176
|
+
};
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2179
|
+
|
|
2180
|
+
|
|
2181
|
+
|
|
2182
|
+
|
|
2183
|
+
|
|
2184
|
+
|
|
2185
|
+
class SetToken {
|
|
2186
|
+
authConfig;
|
|
2187
|
+
constructor(authConfig){
|
|
2188
|
+
this.authConfig = authConfig;
|
|
2189
|
+
}
|
|
2190
|
+
get cookieName() {
|
|
2191
|
+
return this.authConfig?.getRefreshTokenCookieName() ?? auth_constants/* .DEFAULT_COOKIE_NAME */.rv;
|
|
2192
|
+
}
|
|
2193
|
+
get maxAgeMs() {
|
|
2194
|
+
return (0,utils_.parseDurationToMs)(this.authConfig?.getRefreshTokenExpiration() ?? '7d');
|
|
2195
|
+
}
|
|
2196
|
+
intercept(context, next) {
|
|
2197
|
+
const req = context.switchToHttp().getRequest();
|
|
2198
|
+
const res = context.switchToHttp().getResponse();
|
|
2199
|
+
return next.handle().pipe((0,external_rxjs_.map)((value)=>{
|
|
2200
|
+
if (typeof value !== 'object' || value === null) {
|
|
2201
|
+
return value;
|
|
2202
|
+
}
|
|
2203
|
+
const response = value;
|
|
2204
|
+
const data = typeof response['data'] === 'object' && response['data'] !== null ? response['data'] : null;
|
|
2205
|
+
const tokenInData = data && typeof data['refreshToken'] === 'string';
|
|
2206
|
+
if (!tokenInData) {
|
|
2207
|
+
return value;
|
|
2208
|
+
}
|
|
2209
|
+
if (!(0,utils_.isBrowserRequest)(req)) {
|
|
2210
|
+
return value;
|
|
2211
|
+
}
|
|
2212
|
+
this.setRefreshTokenCookie(req, res, data['refreshToken']);
|
|
2213
|
+
const { refreshToken: _, ...dataWithoutToken } = data;
|
|
2214
|
+
return {
|
|
2215
|
+
...response,
|
|
2216
|
+
data: dataWithoutToken
|
|
2217
|
+
};
|
|
2218
|
+
}), (0,external_rxjs_.catchError)((err)=>(0,external_rxjs_.throwError)(()=>err)));
|
|
2219
|
+
}
|
|
2220
|
+
setRefreshTokenCookie(req, res, tokenValue) {
|
|
2221
|
+
const rawCookieString = `${this.cookieName}=${tokenValue}; HttpOnly`;
|
|
2222
|
+
const estimatedBytes = __rspack_external_buffer.Buffer.byteLength(rawCookieString, 'utf8');
|
|
2223
|
+
if (estimatedBytes > (/* inlined export .MAX_COOKIE_BYTES */3500)) {
|
|
2224
|
+
throw new common_.PayloadTooLargeException({
|
|
2225
|
+
message: `Refresh token too large (≈${estimatedBytes} bytes)`,
|
|
2226
|
+
messageKey: message_keys/* .AUTH_MESSAGES.TOKEN_TOO_LARGE */.mK.TOKEN_TOO_LARGE,
|
|
2227
|
+
messageVariables: {
|
|
2228
|
+
size: estimatedBytes
|
|
2229
|
+
}
|
|
2230
|
+
});
|
|
2231
|
+
}
|
|
2232
|
+
res.cookie(this.cookieName, tokenValue, {
|
|
2233
|
+
httpOnly: true,
|
|
2234
|
+
path: '/',
|
|
2235
|
+
maxAge: this.maxAgeMs,
|
|
2236
|
+
...(0,utils_.buildCookieOptions)(req)
|
|
2237
|
+
});
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
SetToken = _ts_decorate([
|
|
2241
|
+
(0,common_.Injectable)(),
|
|
2242
|
+
_ts_param(0, (0,common_.Optional)()),
|
|
2243
|
+
_ts_param(0, (0,common_.Inject)(auth_config_service/* .AuthConfigService */.W)),
|
|
2244
|
+
_ts_metadata("design:type", Function),
|
|
2245
|
+
_ts_metadata("design:paramtypes", [
|
|
2246
|
+
typeof auth_config_service/* .AuthConfigService */.W === "undefined" ? Object : auth_config_service/* .AuthConfigService */.W
|
|
2247
|
+
])
|
|
2248
|
+
], SetToken);
|
|
2249
|
+
|
|
2250
|
+
|
|
2251
|
+
},
|
|
2252
|
+
3513(module) {
|
|
2253
|
+
|
|
2254
|
+
module.exports = __rspack_external__flusys_nestjs_shared_guards_3f79ddd1;
|
|
2255
|
+
|
|
2256
|
+
|
|
2257
|
+
},
|
|
2258
|
+
7271(module) {
|
|
2259
|
+
|
|
2260
|
+
module.exports = __rspack_external_rxjs;
|
|
2261
|
+
|
|
2262
|
+
|
|
2263
|
+
},
|
|
2264
|
+
|
|
2265
|
+
};
|