@punks/backend-entity-manager 0.0.109 → 0.0.111
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/dist/cjs/index.js +27 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/platforms/nest/extensions/authentication/decorators/currentUser.d.ts +6 -0
- package/dist/cjs/types/platforms/nest/extensions/authentication/decorators/index.d.ts +1 -0
- package/dist/esm/index.js +28 -12
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/platforms/nest/extensions/authentication/decorators/currentUser.d.ts +6 -0
- package/dist/esm/types/platforms/nest/extensions/authentication/decorators/index.d.ts +1 -0
- package/dist/index.d.ts +7 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -2342,6 +2342,19 @@ __decorate([
|
|
|
2342
2342
|
__metadata("design:type", Array)
|
|
2343
2343
|
], StringFacet.prototype, "items", void 0);
|
|
2344
2344
|
|
|
2345
|
+
const CurrentUser = common.createParamDecorator((data, context) => {
|
|
2346
|
+
const request = context.switchToHttp().getRequest();
|
|
2347
|
+
if (!request.auth) {
|
|
2348
|
+
return undefined;
|
|
2349
|
+
}
|
|
2350
|
+
const user = request.auth.user;
|
|
2351
|
+
const roles = request.auth.roles;
|
|
2352
|
+
return {
|
|
2353
|
+
user,
|
|
2354
|
+
roles,
|
|
2355
|
+
};
|
|
2356
|
+
});
|
|
2357
|
+
|
|
2345
2358
|
const AuthenticationExtensionSymbols = {
|
|
2346
2359
|
UserService: Symbol.for("WP.EXT:AUTHENTICATION.USER_SERVICE"),
|
|
2347
2360
|
RolesService: Symbol.for("WP.EXT:AUTHENTICATION.ROLES_SERVICE"),
|
|
@@ -2442,14 +2455,15 @@ exports.AuthGuard = AuthGuard_1 = class AuthGuard {
|
|
|
2442
2455
|
});
|
|
2443
2456
|
return isAuthenticated;
|
|
2444
2457
|
}
|
|
2445
|
-
|
|
2458
|
+
const isAuthenticated = !!auth?.user;
|
|
2459
|
+
this.logger.debug(`Authorized:${isAuthenticated} -> auth guard`, {
|
|
2446
2460
|
...this.getContextInfo({
|
|
2447
2461
|
context,
|
|
2448
2462
|
roles: auth?.roles,
|
|
2449
2463
|
user: auth?.user,
|
|
2450
2464
|
}),
|
|
2451
2465
|
});
|
|
2452
|
-
return
|
|
2466
|
+
return isAuthenticated;
|
|
2453
2467
|
}
|
|
2454
2468
|
isRoleMatching(allowedRoles, userRoles) {
|
|
2455
2469
|
return userRoles.some((role) => allowedRoles.includes(role.uid));
|
|
@@ -2486,14 +2500,16 @@ exports.AuthGuard = AuthGuard_1 = class AuthGuard {
|
|
|
2486
2500
|
},
|
|
2487
2501
|
...(user
|
|
2488
2502
|
? {
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2503
|
+
user: {
|
|
2504
|
+
id: user.id,
|
|
2505
|
+
userName: user.userName,
|
|
2506
|
+
email: user.email,
|
|
2507
|
+
roles: roles?.map((role) => ({
|
|
2508
|
+
id: role.id,
|
|
2509
|
+
name: role.name,
|
|
2510
|
+
uid: role.uid,
|
|
2511
|
+
})),
|
|
2512
|
+
},
|
|
2497
2513
|
}
|
|
2498
2514
|
: {}),
|
|
2499
2515
|
};
|
|
@@ -27703,6 +27719,7 @@ exports.AwsS2BucketError = AwsS2BucketError;
|
|
|
27703
27719
|
exports.AwsSesEmailTemplate = AwsSesEmailTemplate;
|
|
27704
27720
|
exports.BooleanFacet = BooleanFacet;
|
|
27705
27721
|
exports.BooleanFacetItem = BooleanFacetItem;
|
|
27722
|
+
exports.CurrentUser = CurrentUser;
|
|
27706
27723
|
exports.EntityManagerConfigurationError = EntityManagerConfigurationError;
|
|
27707
27724
|
exports.EntityManagerException = EntityManagerException;
|
|
27708
27725
|
exports.EntityManagerSymbols = EntityManagerSymbols;
|