monkey-front-core 0.0.349 → 0.0.350

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.
@@ -4117,93 +4117,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
4117
4117
  args: [{ providedIn: 'root' }]
4118
4118
  }], ctorParameters: function () { return [{ type: MonkeyEcxAuthenticationService }]; } });
4119
4119
 
4120
- let MonkeyEcxAuthGuardByRole = class MonkeyEcxAuthGuardByRole {
4120
+ class MonkeyEcxAuthGuardByRole {
4121
4121
  constructor() {
4122
4122
  // not to do
4123
4123
  }
4124
4124
  static forRoles(roles, companyType, byExclusion) {
4125
- class RoleCheck {
4126
- constructor(monkeyecxAuthenticationService, router) {
4127
- this.monkeyecxAuthenticationService = monkeyecxAuthenticationService;
4128
- this.router = router;
4129
- this.tokenCredentials = null;
4130
- // not to do
4131
- }
4132
- navigateToErrorPage() {
4133
- let path = '/app/pages/forbidden';
4134
- if (companyType) {
4135
- path = `/app/${companyType}/pages/forbidden`;
4136
- }
4137
- this.router?.navigate([path.toLowerCase()]);
4138
- }
4139
- getRole() {
4140
- const { tokenCredentials } = this;
4141
- if (!tokenCredentials)
4142
- return '';
4143
- if (tokenCredentials?.programAdmin === 'true') {
4144
- return 'PROGRAM_ADMIN';
4145
- }
4146
- if (tokenCredentials?.programAdmin === true) {
4147
- return 'PROGRAM_ADMIN';
4148
- }
4149
- return tokenCredentials?.role || '';
4150
- }
4151
- allowedSecurityAccess(roles) {
4152
- if (!roles?.length)
4153
- return true;
4154
- const found = roles?.indexOf(this.getRole());
4155
- let ret = false;
4156
- if (byExclusion) {
4157
- ret = true;
4158
- if (found > -1) {
4159
- ret = false;
4160
- }
4161
- }
4162
- else {
4163
- ret = false;
4164
- if (found > -1) {
4165
- ret = true;
4166
- }
4167
- }
4168
- if (!roles || roles.length === 0 || this.getRole() === 'PROGRAM_ADMIN') {
4169
- ret = true;
4170
- }
4171
- return ret;
4172
- }
4173
- async canActivate() {
4174
- console.log('roles');
4175
- console.log(roles);
4176
- if (!this.tokenCredentials) {
4177
- this.tokenCredentials = await this.monkeyecxAuthenticationService.getToken();
4178
- }
4179
- console.log('this.tokenCredentials');
4180
- console.log(this.tokenCredentials);
4181
- console.log('checando');
4182
- if (!this.allowedSecurityAccess(roles)) {
4183
- console.log('checou erro');
4184
- this.navigateToErrorPage();
4185
- return false;
4186
- }
4187
- console.log('checou ok');
4188
- return true;
4189
- }
4190
- }
4191
- RoleCheck.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: RoleCheck, deps: [{ token: MonkeyEcxAuthenticationService }, { token: i2$2.Router }], target: i0.ɵɵFactoryTarget.Injectable });
4192
- RoleCheck.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: RoleCheck, providedIn: 'root' });
4193
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: RoleCheck, decorators: [{
4194
- type: Injectable,
4195
- args: [{
4196
- providedIn: 'root'
4197
- }]
4198
- }], ctorParameters: function () { return [{ type: MonkeyEcxAuthenticationService }, { type: i2$2.Router }]; } });
4199
- return RoleCheck;
4125
+ return 'oi';
4200
4126
  }
4201
- };
4202
- MonkeyEcxAuthGuardByRole = __decorate([
4203
- Injectable({
4204
- providedIn: 'root'
4205
- })
4206
- ], MonkeyEcxAuthGuardByRole);
4127
+ }
4128
+ MonkeyEcxAuthGuardByRole.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxAuthGuardByRole, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
4129
+ MonkeyEcxAuthGuardByRole.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxAuthGuardByRole, providedIn: 'root' });
4130
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxAuthGuardByRole, decorators: [{
4131
+ type: Injectable,
4132
+ args: [{
4133
+ providedIn: 'root'
4134
+ }]
4135
+ }], ctorParameters: function () { return []; } });
4207
4136
 
4208
4137
  class MonkeyEcxAuthGuard {
4209
4138
  constructor(monkeyecxAuthenticationService) {