Skip to content

Commit

Permalink
feat: check currentUser policies
Browse files Browse the repository at this point in the history
  • Loading branch information
syl-p committed Nov 8, 2021
1 parent 61b65f4 commit 0bef80e
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/app/modules/pia/pia.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,20 +184,26 @@ export class PiaComponent implements OnInit, DoCheck {
this.authService.currentUser.subscribe({
complete: () => {
if (this.authService.state) {
// TODO: UPDATE editMode var with current user
this.editMode = [];
switch (this.authService.currentUserValue.id) {
case this.pia.author_name:
this.editMode.push('author');
case this.pia.evaluator_name:
this.editMode.push('evaluator');
case this.pia.validator_name:
this.editMode.push('validator');
default:
this.editMode.push('guest');
console.log(this.authService.currentUserValue);

if (
this.authService.currentUserValue.access_type.includes(
'technique'
) ||
this.authService.currentUserValue.access_type.includes('functional')
) {
this.editMode = ['author', 'validator', 'evaluator', 'guest'];
} else {
this.pia.user_pias.forEach(up => {
if (
up.user.id ===
this.authService.currentUserValue.resource_owner_id
) {
this.editMode.push(up.role);
}
});
}
// TODO: Remove it after test
this.editMode.push('validator');
} else {
this.editMode = 'local';
}
Expand Down

0 comments on commit 0bef80e

Please sign in to comment.