game workflow corrected

This commit is contained in:
magdo
2025-10-30 19:39:41 +01:00
parent 79786d8bb1
commit 9f3a5b6fd7
3 changed files with 16 additions and 6 deletions
@@ -88,10 +88,16 @@ export class DeckAggregate {
@JoinColumn({ name: 'user_id' })
user!: UserAggregate | null;
isEditable() {
isEditable(userId:string): boolean{
// A deck is editable if the user is the creator
return (userId: string) => {
return this.user?.id.toString() === userId;
};
if (!this.user) {
logError(`DeckAggregate.isEditable: User is null for deck id ${this.id}`);
return false;
}
//if admin, always editable
if (this.user?.isAdmin) {
return true;
}
return this.user?.id.toString() === userId;;
}
}
@@ -55,4 +55,8 @@ export class UserAggregate {
@Column({ type: 'timestamp', nullable: true })
Orglogindate!: Date | null;
get isAdmin(): boolean {
return this.state === UserState.ADMIN;
}
}