41 lines
769 B
TypeScript
41 lines
769 B
TypeScript
import {
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
ManyToOne,
|
|
PrimaryGeneratedColumn,
|
|
} from 'typeorm';
|
|
import { User } from '../user/user.entity';
|
|
|
|
export enum UserTokenType {
|
|
GENERIC = 'generic',
|
|
ACTIVATION = 'activation',
|
|
DEACTIVATION = 'deactivation',
|
|
PASSWORD = 'password',
|
|
LOGIN = 'login',
|
|
GDPR = 'gdpr',
|
|
TOTP = 'totp',
|
|
RECOVERY = 'recovery',
|
|
}
|
|
|
|
@Entity()
|
|
export class UserToken {
|
|
@PrimaryGeneratedColumn()
|
|
id: number;
|
|
|
|
@Column({ nullable: false, type: 'text' })
|
|
token: string;
|
|
|
|
@Column({ type: 'enum', enum: UserTokenType, nullable: false })
|
|
type: UserTokenType;
|
|
|
|
@Column({ type: 'timestamp', nullable: true })
|
|
public expires_at: Date;
|
|
|
|
@CreateDateColumn()
|
|
public created_at: Date;
|
|
|
|
@ManyToOne(() => User)
|
|
user: User;
|
|
}
|