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:
@@ -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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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 } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user