fix: re-check canBook() inside export dialog methods (defense in depth)

openExportDialog()/openExportSubscriptionDialog() only guarded on teamId
truthiness, relying solely on the template @if for permission gating.
Every other permission-gated method in Cashbox (submitPlayerBooking,
reverseBooking) re-checks the permission internally too. Add the same
guard here, plus a test asserting direct invocation without booking
rights does not call dialog.open.
This commit is contained in:
Bastian Wagner
2026-08-04 08:59:49 +02:00
parent 1c214c5f06
commit ce0b500d7a
2 changed files with 11 additions and 2 deletions

View File

@@ -306,4 +306,13 @@ describe('Cashbox', () => {
); );
expect(exportButton).toBeUndefined(); expect(exportButton).toBeUndefined();
}); });
it('does not open the export dialogs when invoked directly without booking rights', async () => {
const { component, dialog } = await setup(1);
component['openExportDialog']();
component['openExportSubscriptionDialog']();
expect(dialog.open).not.toHaveBeenCalled();
});
}); });

View File

@@ -402,13 +402,13 @@ export class Cashbox {
protected openExportDialog(): void { protected openExportDialog(): void {
const teamId = this.team()?.id; const teamId = this.team()?.id;
if (!teamId) return; if (!this.canBook() || !teamId) return;
this.dialog.open(CashboxExportDialog, { data: { teamId } }); this.dialog.open(CashboxExportDialog, { data: { teamId } });
} }
protected openExportSubscriptionDialog(): void { protected openExportSubscriptionDialog(): void {
const teamId = this.team()?.id; const teamId = this.team()?.id;
if (!teamId) return; if (!this.canBook() || !teamId) return;
this.dialog.open(CashboxExportSubscriptionDialog, { data: { teamId } }); this.dialog.open(CashboxExportSubscriptionDialog, { data: { teamId } });
} }