monkey-front-core 0.0.345 → 0.0.347
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/monkeyecx-auth-guard-role.service.mjs +51 -53
- package/fesm2015/monkey-front-core.mjs +50 -51
- package/fesm2015/monkey-front-core.mjs.map +1 -1
- package/fesm2020/monkey-front-core.mjs +50 -50
- package/fesm2020/monkey-front-core.mjs.map +1 -1
- package/monkey-front-core-0.0.347.tgz +0 -0
- package/package.json +1 -1
- package/monkey-front-core-0.0.345.tgz +0 -0
|
@@ -4118,79 +4118,79 @@ let MonkeyEcxAuthGuardByRole = class MonkeyEcxAuthGuardByRole {
|
|
|
4118
4118
|
}
|
|
4119
4119
|
static forRoles(roles, companyType, byExclusion) {
|
|
4120
4120
|
class RoleCheck {
|
|
4121
|
-
constructor(
|
|
4122
|
-
this.storageService = storageService;
|
|
4123
|
-
this.router = router;
|
|
4121
|
+
constructor() {
|
|
4124
4122
|
this.tokenCredentials = null;
|
|
4125
4123
|
// not to do
|
|
4126
4124
|
}
|
|
4127
|
-
navigateToErrorPage() {
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4125
|
+
/* private navigateToErrorPage() {
|
|
4126
|
+
let path = '/app/pages/forbidden';
|
|
4127
|
+
if (companyType) {
|
|
4128
|
+
path = `/app/${companyType}/pages/forbidden`;
|
|
4129
|
+
}
|
|
4130
|
+
this.router?.navigate([path.toLowerCase()]);
|
|
4133
4131
|
}
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4132
|
+
|
|
4133
|
+
private getRole(): string {
|
|
4134
|
+
const { tokenCredentials } = this;
|
|
4135
|
+
|
|
4136
|
+
if (!tokenCredentials) return '';
|
|
4137
|
+
if (tokenCredentials?.programAdmin === 'true') {
|
|
4138
|
+
return 'PROGRAM_ADMIN';
|
|
4139
|
+
}
|
|
4140
|
+
if (tokenCredentials?.programAdmin === true) {
|
|
4141
|
+
return 'PROGRAM_ADMIN';
|
|
4142
|
+
}
|
|
4143
|
+
|
|
4144
|
+
return tokenCredentials?.role || '';
|
|
4145
4145
|
}
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
}
|
|
4157
|
-
else {
|
|
4158
|
-
ret = false;
|
|
4159
|
-
if (found > -1) {
|
|
4160
|
-
ret = true;
|
|
4161
|
-
}
|
|
4146
|
+
|
|
4147
|
+
private allowedSecurityAccess(roles: string[]): boolean {
|
|
4148
|
+
if (!roles?.length) return true;
|
|
4149
|
+
|
|
4150
|
+
const found = roles?.indexOf(this.getRole());
|
|
4151
|
+
let ret = false;
|
|
4152
|
+
if (byExclusion) {
|
|
4153
|
+
ret = true;
|
|
4154
|
+
if (found > -1) {
|
|
4155
|
+
ret = false;
|
|
4162
4156
|
}
|
|
4163
|
-
|
|
4164
|
-
|
|
4157
|
+
} else {
|
|
4158
|
+
ret = false;
|
|
4159
|
+
if (found > -1) {
|
|
4160
|
+
ret = true;
|
|
4165
4161
|
}
|
|
4166
|
-
|
|
4167
|
-
|
|
4162
|
+
}
|
|
4163
|
+
if (!roles || roles.length === 0 || this.getRole() === 'PROGRAM_ADMIN') {
|
|
4164
|
+
ret = true;
|
|
4165
|
+
}
|
|
4166
|
+
return ret;
|
|
4167
|
+
} */
|
|
4168
4168
|
async canActivate() {
|
|
4169
4169
|
console.log('roles');
|
|
4170
4170
|
console.log(roles);
|
|
4171
|
-
if (!this.tokenCredentials) {
|
|
4172
|
-
|
|
4173
|
-
}
|
|
4171
|
+
// if (!this.tokenCredentials) {
|
|
4172
|
+
// this.tokenCredentials = await this.storageService.getToken();
|
|
4173
|
+
// }
|
|
4174
4174
|
console.log('this.tokenCredentials');
|
|
4175
4175
|
console.log(this.tokenCredentials);
|
|
4176
4176
|
console.log('checando');
|
|
4177
|
-
if (!this.allowedSecurityAccess(roles)) {
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
}
|
|
4177
|
+
// if (!this.allowedSecurityAccess(roles)) {
|
|
4178
|
+
// console.log('checou erro');
|
|
4179
|
+
// this.navigateToErrorPage();
|
|
4180
|
+
// return false;
|
|
4181
|
+
// }
|
|
4182
4182
|
console.log('checou ok');
|
|
4183
4183
|
return true;
|
|
4184
4184
|
}
|
|
4185
4185
|
}
|
|
4186
|
-
RoleCheck.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: RoleCheck, deps: [
|
|
4186
|
+
RoleCheck.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: RoleCheck, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4187
4187
|
RoleCheck.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: RoleCheck, providedIn: 'root' });
|
|
4188
4188
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: RoleCheck, decorators: [{
|
|
4189
4189
|
type: Injectable,
|
|
4190
4190
|
args: [{
|
|
4191
4191
|
providedIn: 'root'
|
|
4192
4192
|
}]
|
|
4193
|
-
}], ctorParameters: function () { return [
|
|
4193
|
+
}], ctorParameters: function () { return []; } });
|
|
4194
4194
|
return RoleCheck;
|
|
4195
4195
|
}
|
|
4196
4196
|
};
|