tnx-shared 5.1.310 → 5.1.311
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/bundles/tnx-shared.umd.js +96 -9
- package/bundles/tnx-shared.umd.js.map +1 -1
- package/bundles/tnx-shared.umd.min.js +1 -1
- package/bundles/tnx-shared.umd.min.js.map +1 -1
- package/components/common-app-component/common-app-component.d.ts +3 -3
- package/components/common-app-component/common-app-component.d.ts.map +1 -1
- package/esm2015/components/common-app-component/common-app-component.js +5 -5
- package/esm2015/services/permission.service.js +63 -16
- package/esm2015/services/role.service.js +29 -1
- package/fesm2015/tnx-shared.js +90 -15
- package/fesm2015/tnx-shared.js.map +1 -1
- package/package.json +2 -2
- package/services/permission.service.d.ts +6 -4
- package/services/permission.service.d.ts.map +1 -1
- package/services/role.service.d.ts +7 -0
- package/services/role.service.d.ts.map +1 -1
- package/tnx-shared.metadata.json +1 -1
|
@@ -11078,19 +11078,20 @@
|
|
|
11078
11078
|
_this._oauthService = _oauthService;
|
|
11079
11079
|
_this._appContext = _appContext;
|
|
11080
11080
|
_this.storage = sessionStorage;
|
|
11081
|
-
_this.delayCheckPermissions = [];
|
|
11082
11081
|
_this.ignoreAdmin = false;
|
|
11082
|
+
_this.delayCheckPermissions = [];
|
|
11083
11083
|
_this.appCode = null;
|
|
11084
|
-
_this.
|
|
11085
|
-
_this.
|
|
11086
|
-
_this.
|
|
11084
|
+
_this._config = _this._moduleConfigService.getConfig();
|
|
11085
|
+
_this.endPoint = _this._config.environment.apiDomain.authorizationEndpoint;
|
|
11086
|
+
_this.ignoreAdmin = _this._config.environment.isIgnoreAdmin;
|
|
11087
|
+
_this.appCode = _this._config.appCode;
|
|
11087
11088
|
return _this;
|
|
11088
11089
|
}
|
|
11089
11090
|
PermissionService.prototype.clearPermissionCacheAll = function () {
|
|
11090
11091
|
var _a, _b, _c;
|
|
11091
|
-
var lstAppCodes = (_c = (_b = (_a = this.
|
|
11092
|
+
var lstAppCodes = (_c = (_b = (_a = this._config.environment.appMetadata) === null || _a === void 0 ? void 0 : _a.appSwitcher) === null || _b === void 0 ? void 0 : _b.map(function (app) { return app.code; })) !== null && _c !== void 0 ? _c : [];
|
|
11092
11093
|
var lstApiEndpoint = [];
|
|
11093
|
-
var apiDomain = this.
|
|
11094
|
+
var apiDomain = this._config.environment.apiDomain;
|
|
11094
11095
|
for (var domainName in apiDomain) {
|
|
11095
11096
|
if (domainName.startsWith('-') || domainName.startsWith('1') || domainName == 'gateway')
|
|
11096
11097
|
continue;
|
|
@@ -11107,7 +11108,7 @@
|
|
|
11107
11108
|
var url = this.serviceUri + "/GetCurrentUserPermission";
|
|
11108
11109
|
return this.defaultGet(url);
|
|
11109
11110
|
};
|
|
11110
|
-
PermissionService.prototype.getAllBasePermission = function () {
|
|
11111
|
+
PermissionService.prototype.getAllBasePermission = function (userId) {
|
|
11111
11112
|
var _a, _b, _c, _d;
|
|
11112
11113
|
return __awaiter(this, void 0, void 0, function () {
|
|
11113
11114
|
var url, user, res, lstAppCodes, promiseArr, code, service, permissions, key, storageItem;
|
|
@@ -11121,10 +11122,14 @@
|
|
|
11121
11122
|
|| (user.isadmin && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin)) {
|
|
11122
11123
|
return [2 /*return*/];
|
|
11123
11124
|
}
|
|
11125
|
+
if (userId && userId != '' && userId != this._commonService.guidEmpty()) {
|
|
11126
|
+
url += "?userId=" + userId;
|
|
11127
|
+
return [2 /*return*/, this.defaultGet(url)];
|
|
11128
|
+
}
|
|
11124
11129
|
return [4 /*yield*/, this.defaultGet(url)];
|
|
11125
11130
|
case 1:
|
|
11126
11131
|
res = _e.sent();
|
|
11127
|
-
lstAppCodes = (_c = (_b = (_a = this.
|
|
11132
|
+
lstAppCodes = (_c = (_b = (_a = this._config.environment.appMetadata) === null || _a === void 0 ? void 0 : _a.appSwitcher) === null || _b === void 0 ? void 0 : _b.map(function (app) { return app.code; })) !== null && _c !== void 0 ? _c : [];
|
|
11128
11133
|
if (!(!res.success || res.data == null)) return [3 /*break*/, 3];
|
|
11129
11134
|
promiseArr = [];
|
|
11130
11135
|
for (code in lstAppCodes) {
|
|
@@ -11264,9 +11269,10 @@
|
|
|
11264
11269
|
});
|
|
11265
11270
|
}); });
|
|
11266
11271
|
};
|
|
11267
|
-
PermissionService.prototype.checkPermission = function (service,
|
|
11272
|
+
PermissionService.prototype.checkPermission = function (service, permissionToCheck, resolve, reject) {
|
|
11268
11273
|
return __awaiter(this, void 0, void 0, function () {
|
|
11269
11274
|
var user;
|
|
11275
|
+
var _this = this;
|
|
11270
11276
|
return __generator(this, function (_e) {
|
|
11271
11277
|
switch (_e.label) {
|
|
11272
11278
|
case 0: return [4 /*yield*/, this._userService.getCurrentUser()];
|
|
@@ -11278,6 +11284,59 @@
|
|
|
11278
11284
|
});
|
|
11279
11285
|
});
|
|
11280
11286
|
};
|
|
11287
|
+
PermissionService.prototype._checkPermission = function (userPermissions, permissionToCheck) {
|
|
11288
|
+
var e_2, _e;
|
|
11289
|
+
var isAuthorized = false;
|
|
11290
|
+
// check quyền theo cách cũ nếu trường họp là phân quyền module
|
|
11291
|
+
if (permissionToCheck.includes('MODULE')) {
|
|
11292
|
+
return userPermissions.includes(permissionToCheck);
|
|
11293
|
+
}
|
|
11294
|
+
try {
|
|
11295
|
+
for (var userPermissions_1 = __values(userPermissions), userPermissions_1_1 = userPermissions_1.next(); !userPermissions_1_1.done; userPermissions_1_1 = userPermissions_1.next()) {
|
|
11296
|
+
var userPermission = userPermissions_1_1.value;
|
|
11297
|
+
// Cắt chuỗi permission thành mảng để xem mỗi fragement có khớp nhau không
|
|
11298
|
+
var userPermissionFragments = userPermission.split('/');
|
|
11299
|
+
var permissionFragements = permissionToCheck.split('/');
|
|
11300
|
+
// Mảng khác độ dài thì thoát sớm
|
|
11301
|
+
if (userPermissionFragments.length != permissionFragements.length) {
|
|
11302
|
+
continue;
|
|
11303
|
+
}
|
|
11304
|
+
// biến flag ra hiệu người dùng authorized và out vòng
|
|
11305
|
+
var breakLoop = false;
|
|
11306
|
+
// nếu tất cả phần tử khớp nhau => permission này trùng và người dùng được authorized
|
|
11307
|
+
for (var index = 0; index < permissionFragements.length; index++) {
|
|
11308
|
+
var userFragement = userPermissionFragments[index];
|
|
11309
|
+
var permissionFragment = permissionFragements[index];
|
|
11310
|
+
// skip qua các phần tử có ký tự bắt đầu là '{'
|
|
11311
|
+
if (userFragement[0] == '{') {
|
|
11312
|
+
if (index == permissionFragements.length - 1) {
|
|
11313
|
+
isAuthorized = true;
|
|
11314
|
+
breakLoop = true;
|
|
11315
|
+
}
|
|
11316
|
+
continue;
|
|
11317
|
+
}
|
|
11318
|
+
if (userFragement.toLowerCase() != permissionFragment.toLowerCase()) {
|
|
11319
|
+
break;
|
|
11320
|
+
}
|
|
11321
|
+
if (index == permissionFragements.length - 1) {
|
|
11322
|
+
isAuthorized = true;
|
|
11323
|
+
breakLoop = true;
|
|
11324
|
+
}
|
|
11325
|
+
}
|
|
11326
|
+
if (breakLoop) {
|
|
11327
|
+
break;
|
|
11328
|
+
}
|
|
11329
|
+
}
|
|
11330
|
+
}
|
|
11331
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
11332
|
+
finally {
|
|
11333
|
+
try {
|
|
11334
|
+
if (userPermissions_1_1 && !userPermissions_1_1.done && (_e = userPermissions_1.return)) _e.call(userPermissions_1);
|
|
11335
|
+
}
|
|
11336
|
+
finally { if (e_2) throw e_2.error; }
|
|
11337
|
+
}
|
|
11338
|
+
return isAuthorized;
|
|
11339
|
+
};
|
|
11281
11340
|
PermissionService.prototype.isAuthorizedByPermissions = function (permissions, operator, ignoreAdmin) {
|
|
11282
11341
|
var _this = this;
|
|
11283
11342
|
if (operator === void 0) { operator = 'OR'; }
|
|
@@ -35627,6 +35686,34 @@
|
|
|
35627
35686
|
_this._moduleConfig = _moduleConfigService.getConfig();
|
|
35628
35687
|
return _this;
|
|
35629
35688
|
}
|
|
35689
|
+
RoleService.prototype.getDetailCustom = function (id, pid) {
|
|
35690
|
+
var url = this.serviceUri + "/GetDetailCustom/" + id + "?pid=" + pid;
|
|
35691
|
+
return this.defaultGet(url);
|
|
35692
|
+
};
|
|
35693
|
+
RoleService.prototype.GetIdByUsers = function (model) {
|
|
35694
|
+
var url = this.serviceUri + "/GetIdByUsers";
|
|
35695
|
+
return this.defaultPost(url, model);
|
|
35696
|
+
};
|
|
35697
|
+
RoleService.prototype.GetIdByGroupUsers = function (model) {
|
|
35698
|
+
var url = this.serviceUri + "/GetIdByGroupUsers";
|
|
35699
|
+
return this.defaultPost(url, model);
|
|
35700
|
+
};
|
|
35701
|
+
RoleService.prototype.GetIntersectIdByGroupUsers = function (userIds) {
|
|
35702
|
+
var url = this.serviceUri + "/GetIntersectIdByGroupUsers";
|
|
35703
|
+
return this.defaultPost(url, userIds);
|
|
35704
|
+
};
|
|
35705
|
+
RoleService.prototype.GetIntersectDirectIdByGroupUsers = function (userIds) {
|
|
35706
|
+
var url = this.serviceUri + "/GetIntersectDirectIdByGroupUsers";
|
|
35707
|
+
return this.defaultPost(url, userIds);
|
|
35708
|
+
};
|
|
35709
|
+
RoleService.prototype.GetIntersectIdByUsers = function (userIds) {
|
|
35710
|
+
var url = this.serviceUri + "/GetIntersectIdByUsers";
|
|
35711
|
+
return this.defaultPost(url, userIds);
|
|
35712
|
+
};
|
|
35713
|
+
RoleService.prototype.GetIntersectDirectIdByUsers = function (userIds) {
|
|
35714
|
+
var url = this.serviceUri + "/GetIntersectDirectIdByUsers";
|
|
35715
|
+
return this.defaultPost(url, userIds);
|
|
35716
|
+
};
|
|
35630
35717
|
return RoleService;
|
|
35631
35718
|
}(BaseService));
|
|
35632
35719
|
RoleService.ɵprov = i0.ɵɵdefineInjectable({ factory: function RoleService_Factory() { return new RoleService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(ModuleConfigService)); }, token: RoleService, providedIn: "root" });
|