initial
This commit is contained in:
71
src/entity/users.ts
Normal file
71
src/entity/users.ts
Normal file
@ -0,0 +1,71 @@
|
||||
import bcrypt from 'bcryptjs';
|
||||
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn } from 'typeorm';
|
||||
|
||||
import { Role } from '../types/role';
|
||||
import { Status } from '../types/status';
|
||||
|
||||
@Entity('users')
|
||||
export class User {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
unique: true,
|
||||
length: 64
|
||||
})
|
||||
email: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
length: 64,
|
||||
select: false
|
||||
})
|
||||
password: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
unique: true,
|
||||
length: 64
|
||||
})
|
||||
username: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 64
|
||||
})
|
||||
name: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
default: 'STAFF' as Role,
|
||||
length: 30,
|
||||
})
|
||||
role: Role;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
length: 64
|
||||
})
|
||||
status: Status;
|
||||
|
||||
@Column()
|
||||
@CreateDateColumn()
|
||||
created_at: Date;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@UpdateDateColumn()
|
||||
updated_at: Date;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@DeleteDateColumn()
|
||||
deleted_at: Date;
|
||||
|
||||
hashPassword() {
|
||||
this.password = bcrypt.hashSync(this.password, 8);
|
||||
}
|
||||
|
||||
checkIfPasswordMatch(unencryptedPassword: string) {
|
||||
return bcrypt.compareSync(unencryptedPassword, this.password);
|
||||
}
|
||||
}
|
||||
71
src/entity/users_activity.ts
Normal file
71
src/entity/users_activity.ts
Normal file
@ -0,0 +1,71 @@
|
||||
import bcrypt from 'bcryptjs';
|
||||
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn } from 'typeorm';
|
||||
|
||||
import { Role } from '../types/role';
|
||||
import { Status } from '../types/status';
|
||||
|
||||
@Entity('users')
|
||||
export class User {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
unique: true,
|
||||
length: 64
|
||||
})
|
||||
email: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
length: 64,
|
||||
select: false
|
||||
})
|
||||
password: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
unique: true,
|
||||
length: 64
|
||||
})
|
||||
username: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 64
|
||||
})
|
||||
name: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
default: 'STAFF' as Role,
|
||||
length: 30,
|
||||
})
|
||||
role: Role;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
length: 64
|
||||
})
|
||||
status: Status;
|
||||
|
||||
@Column()
|
||||
@CreateDateColumn()
|
||||
created_at: Date;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@UpdateDateColumn()
|
||||
updated_at: Date;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@DeleteDateColumn()
|
||||
deleted_at: Date;
|
||||
|
||||
hashPassword() {
|
||||
this.password = bcrypt.hashSync(this.password, 8);
|
||||
}
|
||||
|
||||
checkIfPasswordMatch(unencryptedPassword: string) {
|
||||
return bcrypt.compareSync(unencryptedPassword, this.password);
|
||||
}
|
||||
}
|
||||
71
src/entity/users_refresh_token.ts
Normal file
71
src/entity/users_refresh_token.ts
Normal file
@ -0,0 +1,71 @@
|
||||
import bcrypt from 'bcryptjs';
|
||||
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn } from 'typeorm';
|
||||
|
||||
import { Role } from '../types/role';
|
||||
import { Status } from '../types/status';
|
||||
|
||||
@Entity('users')
|
||||
export class User {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
unique: true,
|
||||
length: 64
|
||||
})
|
||||
email: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
length: 64,
|
||||
select: false
|
||||
})
|
||||
password: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
unique: true,
|
||||
length: 64
|
||||
})
|
||||
username: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 64
|
||||
})
|
||||
name: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
default: 'STAFF' as Role,
|
||||
length: 30,
|
||||
})
|
||||
role: Role;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
length: 64
|
||||
})
|
||||
status: Status;
|
||||
|
||||
@Column()
|
||||
@CreateDateColumn()
|
||||
created_at: Date;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@UpdateDateColumn()
|
||||
updated_at: Date;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@DeleteDateColumn()
|
||||
deleted_at: Date;
|
||||
|
||||
hashPassword() {
|
||||
this.password = bcrypt.hashSync(this.password, 8);
|
||||
}
|
||||
|
||||
checkIfPasswordMatch(unencryptedPassword: string) {
|
||||
return bcrypt.compareSync(unencryptedPassword, this.password);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user