monkey-front-core 0.0.339 → 0.0.340
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 +67 -69
- package/fesm2015/monkey-front-core.mjs +75 -72
- package/fesm2015/monkey-front-core.mjs.map +1 -1
- package/fesm2020/monkey-front-core.mjs +72 -69
- 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.340.tgz +0 -0
- package/package.json +1 -1
- package/monkey-front-core-0.0.339.tgz +0 -0
|
@@ -4112,85 +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
|
-
|
|
4115
|
+
const forRoles = (roles, companyType, byExclusion) => {
|
|
4116
|
+
class RoleCheck {
|
|
4117
|
+
constructor(storageService, router) {
|
|
4118
|
+
this.storageService = storageService;
|
|
4119
|
+
this.router = router;
|
|
4120
|
+
this.tokenCredentials = null;
|
|
4121
|
+
// not to do
|
|
4122
|
+
}
|
|
4123
|
+
navigateToErrorPage() {
|
|
4124
|
+
let path = '/app/pages/forbidden';
|
|
4125
|
+
if (companyType) {
|
|
4126
|
+
path = `/app/${companyType}/pages/forbidden`;
|
|
4123
4127
|
}
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4128
|
+
this.router?.navigate([path.toLowerCase()]);
|
|
4129
|
+
}
|
|
4130
|
+
getRole() {
|
|
4131
|
+
const { tokenCredentials } = this;
|
|
4132
|
+
if (!tokenCredentials)
|
|
4133
|
+
return '';
|
|
4134
|
+
if (tokenCredentials?.programAdmin === 'true') {
|
|
4135
|
+
return 'PROGRAM_ADMIN';
|
|
4130
4136
|
}
|
|
4131
|
-
|
|
4132
|
-
|
|
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 || '';
|
|
4137
|
+
if (tokenCredentials?.programAdmin === true) {
|
|
4138
|
+
return 'PROGRAM_ADMIN';
|
|
4142
4139
|
}
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
}
|
|
4154
|
-
else {
|
|
4140
|
+
return tokenCredentials?.role || '';
|
|
4141
|
+
}
|
|
4142
|
+
allowedSecurityAccess(roles) {
|
|
4143
|
+
if (!roles?.length)
|
|
4144
|
+
return true;
|
|
4145
|
+
const found = roles?.indexOf(this.getRole());
|
|
4146
|
+
let ret = false;
|
|
4147
|
+
if (byExclusion) {
|
|
4148
|
+
ret = true;
|
|
4149
|
+
if (found > -1) {
|
|
4155
4150
|
ret = false;
|
|
4156
|
-
if (found > -1) {
|
|
4157
|
-
ret = true;
|
|
4158
|
-
}
|
|
4159
4151
|
}
|
|
4160
|
-
|
|
4152
|
+
}
|
|
4153
|
+
else {
|
|
4154
|
+
ret = false;
|
|
4155
|
+
if (found > -1) {
|
|
4161
4156
|
ret = true;
|
|
4162
4157
|
}
|
|
4163
|
-
return ret;
|
|
4164
4158
|
}
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4159
|
+
if (!roles || roles.length === 0 || this.getRole() === 'PROGRAM_ADMIN') {
|
|
4160
|
+
ret = true;
|
|
4161
|
+
}
|
|
4162
|
+
return ret;
|
|
4163
|
+
}
|
|
4164
|
+
async canActivate() {
|
|
4165
|
+
console.log('roles');
|
|
4166
|
+
console.log(roles);
|
|
4167
|
+
if (!this.tokenCredentials) {
|
|
4168
|
+
this.tokenCredentials = await this.storageService.getToken();
|
|
4169
|
+
}
|
|
4170
|
+
console.log('this.tokenCredentials');
|
|
4171
|
+
console.log(this.tokenCredentials);
|
|
4172
|
+
console.log('checando');
|
|
4173
|
+
if (!this.allowedSecurityAccess(roles)) {
|
|
4174
|
+
console.log('checou erro');
|
|
4175
|
+
this.navigateToErrorPage();
|
|
4176
|
+
return false;
|
|
4181
4177
|
}
|
|
4178
|
+
console.log('checou ok');
|
|
4179
|
+
return true;
|
|
4182
4180
|
}
|
|
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;
|
|
4192
4181
|
}
|
|
4193
|
-
}
|
|
4182
|
+
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 });
|
|
4183
|
+
RoleCheck.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: RoleCheck, providedIn: 'root' });
|
|
4184
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: RoleCheck, decorators: [{
|
|
4185
|
+
type: Injectable,
|
|
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
|
+
});
|
|
4194
4197
|
|
|
4195
4198
|
class MonkeyEcxAuthGuard {
|
|
4196
4199
|
constructor(monkeyecxAuthenticationService) {
|
|
@@ -5717,5 +5720,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
5717
5720
|
* Generated bundle index. Do not edit.
|
|
5718
5721
|
*/
|
|
5719
5722
|
|
|
5720
|
-
export { AlertsComponent, AlertsModule, ClosedToMaintenanceComponent, ClosedToMaintenanceModule, CurrencyConfigComponent, CurrencyConfigModule, decoratorsUtils as DecoratorsUtils, Link, MonkeyEcxAlertsService, MonkeyEcxAuthGuard, MonkeyEcxAuthGuardByRole, 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 };
|
|
5723
|
+
export { AlertsComponent, AlertsModule, ClosedToMaintenanceComponent, ClosedToMaintenanceModule, CurrencyConfigComponent, CurrencyConfigModule, decoratorsUtils as DecoratorsUtils, Link, MonkeyEcxAlertsService, MonkeyEcxAuthGuard, monkeyecxAuthGuardRole_service as MonkeyEcxAuthGuardByRole, 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 };
|
|
5721
5724
|
//# sourceMappingURL=monkey-front-core.mjs.map
|