monkey-front-core 0.0.335 → 0.0.337
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 -1
- package/esm2020/lib/core/services/auth/monkeyecx-auth-guard-role.service.mjs +84 -0
- package/esm2020/lib/core/services/commons/monkeyecx-commons.service.mjs +1 -1
- package/fesm2015/monkey-front-core.mjs +84 -1
- package/fesm2015/monkey-front-core.mjs.map +1 -1
- package/fesm2020/monkey-front-core.mjs +81 -1
- package/fesm2020/monkey-front-core.mjs.map +1 -1
- package/lib/core/services/auth/index.d.ts +1 -0
- package/lib/core/services/commons/monkeyecx-commons.service.d.ts +0 -4
- package/monkey-front-core-0.0.337.tgz +0 -0
- package/package.json +1 -1
- package/monkey-front-core-0.0.335.tgz +0 -0
|
@@ -4112,6 +4112,86 @@ 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
|
+
class MonkeyEcxAuthGuardByRole {
|
|
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
|
|
4123
|
+
}
|
|
4124
|
+
navigateToErrorPage() {
|
|
4125
|
+
let path = '/app/pages/forbidden';
|
|
4126
|
+
if (companyType) {
|
|
4127
|
+
path = `/app/${companyType}/pages/forbidden`;
|
|
4128
|
+
}
|
|
4129
|
+
this.router?.navigate([path.toLowerCase()]);
|
|
4130
|
+
}
|
|
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 || '';
|
|
4142
|
+
}
|
|
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 {
|
|
4155
|
+
ret = false;
|
|
4156
|
+
if (found > -1) {
|
|
4157
|
+
ret = true;
|
|
4158
|
+
}
|
|
4159
|
+
}
|
|
4160
|
+
if (!roles || roles.length === 0 || this.getRole() === 'PROGRAM_ADMIN') {
|
|
4161
|
+
ret = true;
|
|
4162
|
+
}
|
|
4163
|
+
return ret;
|
|
4164
|
+
}
|
|
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;
|
|
4181
|
+
}
|
|
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;
|
|
4192
|
+
}
|
|
4193
|
+
}
|
|
4194
|
+
|
|
4115
4195
|
class MonkeyEcxAuthGuard {
|
|
4116
4196
|
constructor(monkeyecxAuthenticationService) {
|
|
4117
4197
|
this.monkeyecxAuthenticationService = monkeyecxAuthenticationService;
|
|
@@ -5637,5 +5717,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
5637
5717
|
* Generated bundle index. Do not edit.
|
|
5638
5718
|
*/
|
|
5639
5719
|
|
|
5640
|
-
export { AlertsComponent, AlertsModule, ClosedToMaintenanceComponent, ClosedToMaintenanceModule, CurrencyConfigComponent, CurrencyConfigModule, decoratorsUtils as DecoratorsUtils, Link, MonkeyEcxAlertsService, MonkeyEcxAuthGuard, 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 };
|
|
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 };
|
|
5641
5721
|
//# sourceMappingURL=monkey-front-core.mjs.map
|