monkey-front-core 0.0.348 → 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.
- package/esm2020/lib/core/services/auth/monkeyecx-auth-guard-role.service.mjs +12 -85
- package/esm2020/lib/core/services/auth/monkeyecx-authentication.service.mjs +6 -1
- package/fesm2015/monkey-front-core.mjs +16 -84
- package/fesm2015/monkey-front-core.mjs.map +1 -1
- package/fesm2020/monkey-front-core.mjs +16 -82
- package/fesm2020/monkey-front-core.mjs.map +1 -1
- package/lib/core/services/auth/monkeyecx-auth-guard-role.service.d.ts +7 -0
- package/lib/core/services/auth/monkeyecx-authentication.service.d.ts +2 -0
- package/monkey-front-core-0.0.350.tgz +0 -0
- package/package.json +1 -1
- package/monkey-front-core-0.0.348.tgz +0 -0
|
@@ -4037,6 +4037,10 @@ class MonkeyEcxAuthenticationService {
|
|
|
4037
4037
|
console.error('refreshToken needs to be declared!');
|
|
4038
4038
|
return null;
|
|
4039
4039
|
};
|
|
4040
|
+
this.getToken = async () => {
|
|
4041
|
+
console.error('getToken needs to be declared!');
|
|
4042
|
+
return null;
|
|
4043
|
+
};
|
|
4040
4044
|
// not to do
|
|
4041
4045
|
}
|
|
4042
4046
|
init(args) {
|
|
@@ -4054,6 +4058,7 @@ class MonkeyEcxAuthenticationService {
|
|
|
4054
4058
|
this.getRequestWithHeadersOb = args?.getRequestWithHeadersOb.bind(this);
|
|
4055
4059
|
this.refreshShouldHappen = args?.refreshShouldHappen || this.refreshShouldHappen.bind(this);
|
|
4056
4060
|
this.refreshToken = args?.refreshToken || this.refreshToken.bind(this);
|
|
4061
|
+
this.getToken = args?.getToken || this.getToken.bind(this);
|
|
4057
4062
|
}
|
|
4058
4063
|
}
|
|
4059
4064
|
MonkeyEcxAuthenticationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxAuthenticationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -4112,93 +4117,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
4112
4117
|
args: [{ providedIn: 'root' }]
|
|
4113
4118
|
}], ctorParameters: function () { return [{ type: MonkeyEcxAuthenticationService }]; } });
|
|
4114
4119
|
|
|
4115
|
-
|
|
4120
|
+
class MonkeyEcxAuthGuardByRole {
|
|
4116
4121
|
constructor() {
|
|
4117
4122
|
// not to do
|
|
4118
4123
|
}
|
|
4119
4124
|
static forRoles(roles, companyType, byExclusion) {
|
|
4120
|
-
|
|
4121
|
-
constructor() {
|
|
4122
|
-
this.tokenCredentials = null;
|
|
4123
|
-
// not to do
|
|
4124
|
-
}
|
|
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()]);
|
|
4131
|
-
}
|
|
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
|
-
}
|
|
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;
|
|
4156
|
-
}
|
|
4157
|
-
} else {
|
|
4158
|
-
ret = false;
|
|
4159
|
-
if (found > -1) {
|
|
4160
|
-
ret = true;
|
|
4161
|
-
}
|
|
4162
|
-
}
|
|
4163
|
-
if (!roles || roles.length === 0 || this.getRole() === 'PROGRAM_ADMIN') {
|
|
4164
|
-
ret = true;
|
|
4165
|
-
}
|
|
4166
|
-
return ret;
|
|
4167
|
-
} */
|
|
4168
|
-
async canActivate() {
|
|
4169
|
-
console.log('roles');
|
|
4170
|
-
console.log(roles);
|
|
4171
|
-
// if (!this.tokenCredentials) {
|
|
4172
|
-
// this.tokenCredentials = await this.storageService.getToken();
|
|
4173
|
-
// }
|
|
4174
|
-
console.log('this.tokenCredentials');
|
|
4175
|
-
console.log(this.tokenCredentials);
|
|
4176
|
-
console.log('checando');
|
|
4177
|
-
// if (!this.allowedSecurityAccess(roles)) {
|
|
4178
|
-
// console.log('checou erro');
|
|
4179
|
-
// this.navigateToErrorPage();
|
|
4180
|
-
// return false;
|
|
4181
|
-
// }
|
|
4182
|
-
console.log('checou ok');
|
|
4183
|
-
return true;
|
|
4184
|
-
}
|
|
4185
|
-
}
|
|
4186
|
-
RoleCheck.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: RoleCheck, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4187
|
-
RoleCheck.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: RoleCheck, providedIn: 'root' });
|
|
4188
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: RoleCheck, decorators: [{
|
|
4189
|
-
type: Injectable,
|
|
4190
|
-
args: [{
|
|
4191
|
-
providedIn: 'root'
|
|
4192
|
-
}]
|
|
4193
|
-
}], ctorParameters: function () { return []; } });
|
|
4194
|
-
return RoleCheck;
|
|
4125
|
+
return 'oi';
|
|
4195
4126
|
}
|
|
4196
|
-
}
|
|
4197
|
-
MonkeyEcxAuthGuardByRole =
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
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 []; } });
|
|
4202
4136
|
|
|
4203
4137
|
class MonkeyEcxAuthGuard {
|
|
4204
4138
|
constructor(monkeyecxAuthenticationService) {
|