monkey-front-core 0.0.351 → 0.0.352
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 +18 -72
- package/fesm2015/monkey-front-core.mjs +15 -72
- package/fesm2015/monkey-front-core.mjs.map +1 -1
- package/fesm2020/monkey-front-core.mjs +15 -71
- package/fesm2020/monkey-front-core.mjs.map +1 -1
- package/monkey-front-core-0.0.352.tgz +0 -0
- package/package.json +1 -1
- package/monkey-front-core-0.0.351.tgz +0 -0
|
@@ -4117,88 +4117,32 @@ 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(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
4126
|
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
4127
|
return true;
|
|
4189
4128
|
}
|
|
4190
4129
|
}
|
|
4130
|
+
RoleCheck.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: RoleCheck, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4131
|
+
RoleCheck.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: RoleCheck, providedIn: 'root' });
|
|
4132
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: RoleCheck, decorators: [{
|
|
4133
|
+
type: Injectable,
|
|
4134
|
+
args: [{
|
|
4135
|
+
providedIn: 'root'
|
|
4136
|
+
}]
|
|
4137
|
+
}] });
|
|
4191
4138
|
return RoleCheck;
|
|
4192
4139
|
}
|
|
4193
|
-
}
|
|
4194
|
-
MonkeyEcxAuthGuardByRole
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
providedIn: 'root'
|
|
4200
|
-
}]
|
|
4201
|
-
}], ctorParameters: function () { return []; } });
|
|
4140
|
+
};
|
|
4141
|
+
MonkeyEcxAuthGuardByRole = __decorate([
|
|
4142
|
+
Injectable({
|
|
4143
|
+
providedIn: 'root'
|
|
4144
|
+
})
|
|
4145
|
+
], MonkeyEcxAuthGuardByRole);
|
|
4202
4146
|
|
|
4203
4147
|
class MonkeyEcxAuthGuard {
|
|
4204
4148
|
constructor(monkeyecxAuthenticationService) {
|