@ubs-platform/users-mona-roles 1.1.4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +3 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/guards/role-guard.guard.js +1 -4
- package/dist/lib/guards/role-guard.guard.js.map +1 -1
- package/dist/lib/match-role.d.ts +1 -1
- package/dist/lib/match-role.js +5 -4
- package/dist/lib/match-role.js.map +1 -1
- package/package.json +33 -1
package/dist/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
export * from './lib/backend-global-ubs-roles.module';
|
2
|
-
export * from
|
3
|
-
export * from
|
4
|
-
export * from
|
2
|
+
export * from './lib/guards/role-guard.guard';
|
3
|
+
export * from './lib/decorator/roles.decorator';
|
4
|
+
export * from './lib/match-role';
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,gFAAsD;AACtD,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,gFAAsD;AACtD,wEAA8C;AAC9C,0EAAgD;AAChD,2DAAiC"}
|
@@ -15,12 +15,9 @@ let RolesGuard = class RolesGuard {
|
|
15
15
|
if (!roles) {
|
16
16
|
return true;
|
17
17
|
}
|
18
|
-
else {
|
19
|
-
roles.push('ADMIN');
|
20
|
-
}
|
21
18
|
const request = context.switchToHttp().getRequest();
|
22
19
|
const user = request.user;
|
23
|
-
return (0, match_role_1.
|
20
|
+
return (0, match_role_1.matchRolesOrAdm)(roles, user.roles);
|
24
21
|
}
|
25
22
|
};
|
26
23
|
exports.RolesGuard = RolesGuard;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"role-guard.guard.js","sourceRoot":"","sources":["../../../src/lib/guards/role-guard.guard.ts"],"names":[],"mappings":";;;;AAAA,2CAA2E;AAC3E,uCAAyC;AACzC,kEAAqD;AACrD,
|
1
|
+
{"version":3,"file":"role-guard.guard.js","sourceRoot":"","sources":["../../../src/lib/guards/role-guard.guard.ts"],"names":[],"mappings":";;;;AAAA,2CAA2E;AAC3E,uCAAyC;AACzC,kEAAqD;AACrD,8CAAgD;AAIzC,IAAM,UAAU,GAAhB,MAAM,UAAU;IACrB,YAAoB,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAE5C,WAAW,CAAC,OAAyB;QACnC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,uBAAK,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;QAC9D,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,MAAM,IAAI,GAAG,OAAO,CAAC,IAA0B,CAAC;QAChD,OAAO,IAAA,4BAAe,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;CACF,CAAA;AAZY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;6CAEoB,gBAAS;GAD7B,UAAU,CAYtB"}
|
package/dist/lib/match-role.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export declare function
|
1
|
+
export declare function matchRolesOrAdm(roles: string[], userRoles: string[]): boolean;
|
package/dist/lib/match-role.js
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
4
|
-
function
|
5
|
-
return
|
3
|
+
exports.matchRolesOrAdm = void 0;
|
4
|
+
function matchRolesOrAdm(roles, userRoles) {
|
5
|
+
return (userRoles.includes('ADMIN') ||
|
6
|
+
roles.reduce((a, b) => a || userRoles.includes(b), false));
|
6
7
|
}
|
7
|
-
exports.
|
8
|
+
exports.matchRolesOrAdm = matchRolesOrAdm;
|
8
9
|
//# sourceMappingURL=match-role.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"match-role.js","sourceRoot":"","sources":["../../src/lib/match-role.ts"],"names":[],"mappings":";;;AAAA,SAAgB,
|
1
|
+
{"version":3,"file":"match-role.js","sourceRoot":"","sources":["../../src/lib/match-role.ts"],"names":[],"mappings":";;;AAAA,SAAgB,eAAe,CAAC,KAAe,EAAE,SAAmB;IAClE,OAAO,CACL,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC3B,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAC1D,CAAC;AACJ,CAAC;AALD,0CAKC"}
|
package/package.json
CHANGED
@@ -1 +1,33 @@
|
|
1
|
-
{
|
1
|
+
{
|
2
|
+
"name": "@ubs-platform/users-mona-roles",
|
3
|
+
"version": "2.0.0",
|
4
|
+
"private": false,
|
5
|
+
"main": "dist/index.js",
|
6
|
+
"license": "MIT",
|
7
|
+
"author": "Unlimited Bundle Systems",
|
8
|
+
"homepage": "https://github.com/ubs-platform/users-mona-roles",
|
9
|
+
"repository": {
|
10
|
+
"type": "git",
|
11
|
+
"url": "https://github.com/ubs-platform/users-mona-roles"
|
12
|
+
},
|
13
|
+
"scripts": {
|
14
|
+
"build": "tsc",
|
15
|
+
"build-publish": "npm run build && npm publish"
|
16
|
+
},
|
17
|
+
"peerDependencies": {
|
18
|
+
"@nestjs/common": "^10.0.2",
|
19
|
+
"@nestjs/core": "^10.0.2",
|
20
|
+
"@ubs-platform/users-common": "2.0.0"
|
21
|
+
},
|
22
|
+
"dependencies": {
|
23
|
+
"tslib": "^2.3.0",
|
24
|
+
"crypto-promise": "^2.1.0"
|
25
|
+
},
|
26
|
+
"devDependencies": {
|
27
|
+
"typescript": "~5.3.2",
|
28
|
+
"@types/node": "~18.16.9"
|
29
|
+
},
|
30
|
+
"publishConfig": {
|
31
|
+
"access": "public"
|
32
|
+
}
|
33
|
+
}
|