monkey-front-core 0.0.341 → 0.0.342
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/esm2020/lib/core/services/auth/index.mjs +2 -2
- package/esm2020/lib/core/services/auth/monkeyecx-auth-guard-role.service.mjs +73 -66
- package/fesm2015/monkey-front-core.mjs +75 -75
- package/fesm2015/monkey-front-core.mjs.map +1 -1
- package/fesm2020/monkey-front-core.mjs +72 -72
- package/fesm2020/monkey-front-core.mjs.map +1 -1
- package/lib/core/services/auth/index.d.ts +1 -1
- package/monkey-front-core-0.0.342.tgz +0 -0
- package/package.json +1 -1
- package/monkey-front-core-0.0.341.tgz +0 -0
|
@@ -4112,88 +4112,88 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
4112
4112
|
args: [{ providedIn: 'root' }]
|
|
4113
4113
|
}], ctorParameters: function () { return [{ type: MonkeyEcxAuthenticationService }]; } });
|
|
4114
4114
|
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
navigateToErrorPage() {
|
|
4124
|
-
let path = '/app/pages/forbidden';
|
|
4125
|
-
if (companyType) {
|
|
4126
|
-
path = `/app/${companyType}/pages/forbidden`;
|
|
4115
|
+
let MonkeyEcxAuthGuardByRoleService = class MonkeyEcxAuthGuardByRoleService {
|
|
4116
|
+
static forRoles(roles, companyType, byExclusion) {
|
|
4117
|
+
class RoleCheck {
|
|
4118
|
+
constructor(storageService, router) {
|
|
4119
|
+
this.storageService = storageService;
|
|
4120
|
+
this.router = router;
|
|
4121
|
+
this.tokenCredentials = null;
|
|
4122
|
+
// not to do
|
|
4127
4123
|
}
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
if (tokenCredentials?.programAdmin === 'true') {
|
|
4135
|
-
return 'PROGRAM_ADMIN';
|
|
4124
|
+
navigateToErrorPage() {
|
|
4125
|
+
let path = '/app/pages/forbidden';
|
|
4126
|
+
if (companyType) {
|
|
4127
|
+
path = `/app/${companyType}/pages/forbidden`;
|
|
4128
|
+
}
|
|
4129
|
+
this.router?.navigate([path.toLowerCase()]);
|
|
4136
4130
|
}
|
|
4137
|
-
|
|
4138
|
-
|
|
4131
|
+
getRole() {
|
|
4132
|
+
const { tokenCredentials } = this;
|
|
4133
|
+
if (!tokenCredentials)
|
|
4134
|
+
return '';
|
|
4135
|
+
if (tokenCredentials?.programAdmin === 'true') {
|
|
4136
|
+
return 'PROGRAM_ADMIN';
|
|
4137
|
+
}
|
|
4138
|
+
if (tokenCredentials?.programAdmin === true) {
|
|
4139
|
+
return 'PROGRAM_ADMIN';
|
|
4140
|
+
}
|
|
4141
|
+
return tokenCredentials?.role || '';
|
|
4139
4142
|
}
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4143
|
+
allowedSecurityAccess(roles) {
|
|
4144
|
+
if (!roles?.length)
|
|
4145
|
+
return true;
|
|
4146
|
+
const found = roles?.indexOf(this.getRole());
|
|
4147
|
+
let ret = false;
|
|
4148
|
+
if (byExclusion) {
|
|
4149
|
+
ret = true;
|
|
4150
|
+
if (found > -1) {
|
|
4151
|
+
ret = false;
|
|
4152
|
+
}
|
|
4153
|
+
}
|
|
4154
|
+
else {
|
|
4150
4155
|
ret = false;
|
|
4156
|
+
if (found > -1) {
|
|
4157
|
+
ret = true;
|
|
4158
|
+
}
|
|
4151
4159
|
}
|
|
4152
|
-
|
|
4153
|
-
else {
|
|
4154
|
-
ret = false;
|
|
4155
|
-
if (found > -1) {
|
|
4160
|
+
if (!roles || roles.length === 0 || this.getRole() === 'PROGRAM_ADMIN') {
|
|
4156
4161
|
ret = true;
|
|
4157
4162
|
}
|
|
4163
|
+
return ret;
|
|
4158
4164
|
}
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
this.navigateToErrorPage();
|
|
4176
|
-
return false;
|
|
4165
|
+
async canActivate() {
|
|
4166
|
+
console.log('roles');
|
|
4167
|
+
console.log(roles);
|
|
4168
|
+
if (!this.tokenCredentials) {
|
|
4169
|
+
this.tokenCredentials = await this.storageService.getToken();
|
|
4170
|
+
}
|
|
4171
|
+
console.log('this.tokenCredentials');
|
|
4172
|
+
console.log(this.tokenCredentials);
|
|
4173
|
+
console.log('checando');
|
|
4174
|
+
if (!this.allowedSecurityAccess(roles)) {
|
|
4175
|
+
console.log('checou erro');
|
|
4176
|
+
this.navigateToErrorPage();
|
|
4177
|
+
return false;
|
|
4178
|
+
}
|
|
4179
|
+
console.log('checou ok');
|
|
4180
|
+
return true;
|
|
4177
4181
|
}
|
|
4178
|
-
console.log('checou ok');
|
|
4179
|
-
return true;
|
|
4180
4182
|
}
|
|
4183
|
+
RoleCheck.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: RoleCheck, deps: [{ token: MonkeyEcxTokenStorageService }, { token: i2$2.Router }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4184
|
+
RoleCheck.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: RoleCheck, providedIn: 'root' });
|
|
4185
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: RoleCheck, decorators: [{
|
|
4186
|
+
type: Injectable,
|
|
4187
|
+
args: [{
|
|
4188
|
+
providedIn: 'root'
|
|
4189
|
+
}]
|
|
4190
|
+
}], ctorParameters: function () { return [{ type: MonkeyEcxTokenStorageService }, { type: i2$2.Router }]; } });
|
|
4191
|
+
return RoleCheck;
|
|
4181
4192
|
}
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
args: [{
|
|
4187
|
-
providedIn: 'root'
|
|
4188
|
-
}]
|
|
4189
|
-
}], ctorParameters: function () { return [{ type: MonkeyEcxTokenStorageService }, { type: i2$2.Router }]; } });
|
|
4190
|
-
return RoleCheck;
|
|
4191
|
-
};
|
|
4192
|
-
|
|
4193
|
-
var monkeyecxAuthGuardRole_service = /*#__PURE__*/Object.freeze({
|
|
4194
|
-
__proto__: null,
|
|
4195
|
-
forRoles: forRoles
|
|
4196
|
-
});
|
|
4193
|
+
};
|
|
4194
|
+
MonkeyEcxAuthGuardByRoleService = __decorate([
|
|
4195
|
+
Injectable({ providedIn: 'root' })
|
|
4196
|
+
], MonkeyEcxAuthGuardByRoleService);
|
|
4197
4197
|
|
|
4198
4198
|
class MonkeyEcxAuthGuard {
|
|
4199
4199
|
constructor(monkeyecxAuthenticationService) {
|
|
@@ -5720,5 +5720,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
5720
5720
|
* Generated bundle index. Do not edit.
|
|
5721
5721
|
*/
|
|
5722
5722
|
|
|
5723
|
-
export { AlertsComponent, AlertsModule, ClosedToMaintenanceComponent, ClosedToMaintenanceModule, CurrencyConfigComponent, CurrencyConfigModule, decoratorsUtils as DecoratorsUtils, Link, MonkeyEcxAlertsService, MonkeyEcxAuthGuard,
|
|
5723
|
+
export { AlertsComponent, AlertsModule, ClosedToMaintenanceComponent, ClosedToMaintenanceModule, CurrencyConfigComponent, CurrencyConfigModule, decoratorsUtils as DecoratorsUtils, Link, MonkeyEcxAlertsService, MonkeyEcxAuthGuard, MonkeyEcxAuthGuardByRoleService, MonkeyEcxAuthGuardCompany, MonkeyEcxAuthGuardLogin, MonkeyEcxAuthenticationService, MonkeyEcxBlobSecurePipe, MonkeyEcxCommonsService, MonkeyEcxConfigModule, MonkeyEcxConfigService, MonkeyEcxCookieStorageService, MonkeyEcxCoreCharts, MonkeyEcxCoreClearDecorators, MonkeyEcxCoreLog, MonkeyEcxCoreService, MonkeyEcxCoreServiceConstructor, MonkeyEcxCoreServicePaged, MonkeyEcxCoreServiceQueue, MonkeyEcxCurrencyConfigService, MonkeyEcxDirectivesModule, MonkeyEcxDiscoveryParamsService, MonkeyEcxDisplayFirstNamePipe, MonkeyEcxDisplayInitialsPipe, MonkeyEcxDragDropDirective, MonkeyEcxErrorConfigService, MonkeyEcxErrorHandlingModule, MonkeyEcxErrorHandlingService, MonkeyEcxFeatureByProgramDirective, MonkeyEcxFeatureDirective, MonkeyEcxFeatureToggleService, MonkeyEcxFormatAddressPipe, MonkeyEcxFormatBeaufityJSONPipe, MonkeyEcxFormatCurrency, MonkeyEcxFormatCurrencyPipe, MonkeyEcxFormatDateGroupPipe, MonkeyEcxFormatDateTimelapsePipe, MonkeyEcxFormatDateUnixTimelapsePipe, MonkeyEcxFormatDocumentPipe, MonkeyEcxFormatDocumentTypePipe, MonkeyEcxFormatNumberPipe, MonkeyEcxFormatPhonePipe, MonkeyEcxFormatSizePipe, MonkeyEcxFormatTaxPipe, MonkeyEcxFormatUpper, MonkeyEcxFormatValue, MonkeyEcxFormatZipCodePipe, MonkeyEcxHandlingService, MonkeyEcxHttpConfigErrorInterceptor, MonkeyEcxHttpConfigHeaderInterceptor, MonkeyEcxHttpConfigInterceptorModule, MonkeyEcxHttpConfigLoadingInProgressInterceptor, MonkeyEcxHttpConfigQueueInterceptor, MonkeyEcxHttpErrorHandlingService, MonkeyEcxLoggedHandlingService, MonkeyEcxLogsConfigService, MonkeyEcxMaintenanceConfigService, MonkeyEcxModel, MonkeyEcxOnlyAlphaNumericDirective, MonkeyEcxOnlyNumbersDirective, MonkeyEcxOthersErrorsHandlingService, MonkeyEcxPaginationService, MonkeyEcxPipesModule, MonkeyEcxPopoverDirective, MonkeyEcxPopoverOptionsDirective, MonkeyEcxProgressBarComponent, MonkeyEcxProgressBarModule, MonkeyEcxProgressBarService, MonkeyEcxRequestDownloadHandlingService, MonkeyEcxRequestDownloadedHandlingService, MonkeyEcxRequestPagedHandling, MonkeyEcxRequestQueueHandlingService, MonkeyEcxRequestQueueModalHandlingService, MonkeyEcxRequestScheduleService, MonkeyEcxSecurityConsoleConfigService, MonkeyEcxSecurityDirective, MonkeyEcxService, MonkeyEcxServiceDownload, MonkeyEcxServiceUpload, MonkeyEcxServiceWorkerConfigService, MonkeyEcxSpecificationSearch, MonkeyEcxTextTruncatePipe, MonkeyEcxTokenStorageService, MonkeyEcxTooltipDirective, MonkeyEcxTruncateQtdPipe, MonkeyEcxUtils, MonkeyEcxi18nConfigService, MonkeyFrontCoreModule, OpSearch, POPOVER_OPTIONS, statics as Statics, validateUtils as ValidateUtils, Validators, VersionChangedComponent, VersionChangedModule, comboValidator, dateRangeValidator, dateStartEndValidator, dateValidator, documentValidator, emailValidator, passwordConfirmValidator, registerValidator, index as store, trueValidator, urlValidator, valueGreaterThanZero, zipCodeValidator };
|
|
5724
5724
|
//# sourceMappingURL=monkey-front-core.mjs.map
|