monkey-front-core 0.0.351 → 0.0.353
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 +19 -70
- package/fesm2015/monkey-front-core.mjs +16 -70
- package/fesm2015/monkey-front-core.mjs.map +1 -1
- package/fesm2020/monkey-front-core.mjs +16 -69
- package/fesm2020/monkey-front-core.mjs.map +1 -1
- package/monkey-front-core-0.0.353.tgz +0 -0
- package/package.json +1 -1
- package/monkey-front-core-0.0.351.tgz +0 -0
|
@@ -4117,88 +4117,35 @@ 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
|
-
class MonkeyEcxAuthGuardByRole {
|
|
4120
|
+
let MonkeyEcxAuthGuardByRole = class MonkeyEcxAuthGuardByRole {
|
|
4121
4121
|
constructor() {
|
|
4122
4122
|
// not to do
|
|
4123
4123
|
}
|
|
4124
4124
|
static forRoles(roles, companyType, byExclusion) {
|
|
4125
4125
|
class RoleCheck {
|
|
4126
|
-
constructor(
|
|
4127
|
-
this.monkeyecxAuthenticationService = monkeyecxAuthenticationService;
|
|
4128
|
-
this.router = router;
|
|
4129
|
-
this.tokenCredentials = null;
|
|
4126
|
+
constructor() {
|
|
4130
4127
|
// not to do
|
|
4131
4128
|
}
|
|
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
4129
|
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
4130
|
return true;
|
|
4189
4131
|
}
|
|
4190
4132
|
}
|
|
4133
|
+
RoleCheck.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: RoleCheck, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4134
|
+
RoleCheck.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: RoleCheck, providedIn: 'root' });
|
|
4135
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: RoleCheck, decorators: [{
|
|
4136
|
+
type: Injectable,
|
|
4137
|
+
args: [{
|
|
4138
|
+
providedIn: 'root'
|
|
4139
|
+
}]
|
|
4140
|
+
}], ctorParameters: function () { return []; } });
|
|
4191
4141
|
return RoleCheck;
|
|
4192
4142
|
}
|
|
4193
|
-
}
|
|
4194
|
-
MonkeyEcxAuthGuardByRole
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
providedIn: 'root'
|
|
4200
|
-
}]
|
|
4201
|
-
}], ctorParameters: function () { return []; } });
|
|
4143
|
+
};
|
|
4144
|
+
MonkeyEcxAuthGuardByRole = __decorate([
|
|
4145
|
+
Injectable({
|
|
4146
|
+
providedIn: 'root'
|
|
4147
|
+
})
|
|
4148
|
+
], MonkeyEcxAuthGuardByRole);
|
|
4202
4149
|
|
|
4203
4150
|
class MonkeyEcxAuthGuard {
|
|
4204
4151
|
constructor(monkeyecxAuthenticationService) {
|