icynet-auth-server/src/modules/objects/oauth2-client/oauth2-client.entity.ts

65 lines
1.4 KiB
TypeScript
Raw Normal View History

2022-03-09 18:37:04 +00:00
import {
Column,
CreateDateColumn,
Entity,
OneToMany,
OneToOne,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import { Upload } from '../upload/upload.entity';
import { User } from '../user/user.entity';
import { OAuth2ClientURL } from './oauth2-client-url.entity';
@Entity()
export class OAuth2Client {
@PrimaryGeneratedColumn()
id: number;
@Column({ type: 'uuid', length: 36, nullable: false, unique: true })
client_id: string;
@Column({ type: 'text', nullable: false })
client_secret: string;
@Column({ nullable: false })
title: string;
@Column({ type: 'text', nullable: true })
description: string;
@Column({ type: 'text', nullable: true })
scope: string;
@Column({ type: 'text', default: 'authorization_code' })
grants: string;
@Column({ default: false })
activated: boolean;
@Column({ default: false })
verified: boolean;
@CreateDateColumn({
type: 'timestamp',
default: () => 'CURRENT_TIMESTAMP(6)',
})
public created_at: Date;
@UpdateDateColumn({
type: 'timestamp',
default: () => 'CURRENT_TIMESTAMP(6)',
onUpdate: 'CURRENT_TIMESTAMP(6)',
})
public updated_at: Date;
@OneToOne(() => Upload, { nullable: true, onDelete: 'SET NULL' })
public picture: Upload;
@OneToOne(() => User, { nullable: true, onDelete: 'SET NULL' })
public owner: User;
@OneToMany(() => OAuth2ClientURL, (url) => url.client)
public urls: OAuth2ClientURL[];
}