Skip to content

Conversation

@ChemMitch
Copy link
Collaborator

@ChemMitch ChemMitch commented Oct 28, 2025

Ready to merge now

got user creation/editing to use configured roles
diagnostic logs
added a method to auth.service to allow checking a set of privileges
(any that match yields a true response)
@ChemMitch ChemMitch changed the title WIP Role rework Role rework Jan 23, 2026
console.log(' has priv to configure system');
return true;
} else {
this.router.parseUrl('/home');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.router.parseUrl('/home');
return this.router.parseUrl('/home');

console.log('user CAN');
return true;
} else {
this.router.parseUrl('/home');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.router.parseUrl('/home');
return this.router.parseUrl('/home');

<a class = "mat-icon-button" aria-label = "edit substance" mat-icon-button [routerLink]="['/substances', substance.uuid, 'edit']" *ngIf="isAdmin"
matTooltip='edit record'>
<a class = "mat-icon-button" aria-label = "edit substance" mat-icon-button [routerLink]="['/substances', substance.uuid, 'edit']"
*ngIf="canImportData" matTooltip='edit record'>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*ngIf="canImportData" matTooltip='edit record'>
*ngIf="canUserImportData" matTooltip='edit record'>

console.log(`in admin.component ngOnInit`);
await this.checkPrivileges();

this.activatedRoute.params.subscribe(routeParams => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we unsubscribe here?

const privs = await firstValueFrom(this.fetchPrivs());
return privs.some(p => p.privilege === 'Edit');
}
return this._privileges != null && this._privileges.some(p=>p.privilege=="Edit");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return this._privileges != null && this._privileges.some(p=>p.privilege=="Edit");
return this._privileges != null && this._privileges.some(p=>p.privilege=="Edit");

const auth = this.authService.getAuth();
if (auth) {
console.log(` got auth `);
const canImporNow = await this.authService.hasSpecificPrivilege("Import Data");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const canImporNow = await this.authService.hasSpecificPrivilege("Import Data");
const canImportNow = await this.authService.hasSpecificPrivilege("Import Data");

response: any;
isError: boolean = false;
availableRoleNames: string[];
assignableRoles: any[];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type safety imporvement e.g.
interface AssignableRole {
roleName: string;
assigned: boolean;
}
assignableRoles: AssignableRole[];


default: this.activeTab = 0; break;
}
this.subscriptions.push(routeSub);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're pushing subscription inside subscribe callback.That's wrong

if( this.activeTab <= -1) {
this.router.navigate(['/home' ] );
}
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be after callback here.
this.subscriptions.push(routeSub);

When you fix that you can simplify ngOnDestroy back to:
ngOnDestroy() {
this.subscriptions.forEach(sub => sub?.unsubscribe());
}

And test it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants