File size: 1,021 Bytes
a38b26a
 
 
 
 
 
 
 
 
9f03bd9
 
a38b26a
 
 
 
 
 
fcab6da
a38b26a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9f03bd9
a38b26a
9f03bd9
a38b26a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
  ManyToOne,
  JoinColumn,
} from 'typeorm';
import type { Relation } from 'typeorm';
import type { User } from './user.entity';

@Entity('two_factor_auth')
export class TwoFactorAuth {
  @PrimaryGeneratedColumn({ name: 'auth_id' })
  authId: number;

  @Column({ name: 'user_id', type: 'bigint', unsigned: true })
  userId: number;

  @Column({ name: 'secret_key', length: 255, nullable: true })
  secretKey?: string;

  @Column({ default: false })
  enabled: boolean;

  @Column({ name: 'backup_codes', type: 'text', nullable: true })
  backupCodes?: string;

  @Column({ name: 'last_used_at', type: 'datetime', nullable: true })
  lastUsedAt?: Date;

  @CreateDateColumn({ name: 'created_at' })
  createdAt: Date;

  @UpdateDateColumn({ name: 'updated_at' })
  updatedAt: Date;

  // Relationships
  @ManyToOne('User', 'twoFactorAuths', { onDelete: 'CASCADE' })
  @JoinColumn({ name: 'user_id' })
  user: Relation<User>;
}