42 lines
792 B
TypeScript
42 lines
792 B
TypeScript
import {
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
ManyToOne,
|
|
PrimaryGeneratedColumn,
|
|
} from 'typeorm';
|
|
import { User } from './user.entity';
|
|
|
|
export enum UserTokenType {
|
|
GENERIC = 'generic',
|
|
ACTIVATION = 'activation',
|
|
DEACTIVATION = 'deactivation',
|
|
PASSWORD = 'password',
|
|
LOGIN = 'login',
|
|
GDPR = 'gdpr',
|
|
}
|
|
|
|
@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({
|
|
type: 'timestamp',
|
|
default: () => 'CURRENT_TIMESTAMP(6)',
|
|
})
|
|
public created_at: Date;
|
|
|
|
@ManyToOne(() => User)
|
|
user: User;
|
|
}
|