cascade deletes of auth method/session FKs
This commit is contained in:
parent
1e57731b08
commit
957cc8f38c
|
@ -15,7 +15,10 @@ export class AuthMethod {
|
||||||
@Column({type: 'varchar', length: 500, nullable: false})
|
@Column({type: 'varchar', length: 500, nullable: false})
|
||||||
userIdentifier!: string;
|
userIdentifier!: string;
|
||||||
|
|
||||||
@ManyToOne(() => User, user => user.authMethods)
|
@ManyToOne(() => User, user => user.authMethods, {
|
||||||
|
cascade: ['remove'],
|
||||||
|
onDelete: 'CASCADE',
|
||||||
|
})
|
||||||
user!: User;
|
user!: User;
|
||||||
|
|
||||||
@BeforeInsert()
|
@BeforeInsert()
|
||||||
|
|
|
@ -10,7 +10,10 @@ export class AuthSession {
|
||||||
@PrimaryColumn({type: 'varchar', length: 26, nullable: false})
|
@PrimaryColumn({type: 'varchar', length: 26, nullable: false})
|
||||||
id = ulidMonotonic();
|
id = ulidMonotonic();
|
||||||
|
|
||||||
@ManyToOne(() => AuthMethod, authMethod => authMethod.id, {nullable: false})
|
@ManyToOne(() => AuthMethod, authMethod => authMethod.id, {
|
||||||
|
cascade: ['remove'],
|
||||||
|
onDelete: 'CASCADE',
|
||||||
|
})
|
||||||
authMethod!: AuthMethod;
|
authMethod!: AuthMethod;
|
||||||
|
|
||||||
// TODO expiration of sessions?
|
// TODO expiration of sessions?
|
||||||
|
|
Loading…
Reference in a new issue