update user, auth, token, roles, done

This commit is contained in:
2024-11-26 23:58:38 +07:00
parent 6e71588f91
commit 9608e96401
27 changed files with 1842 additions and 152 deletions

View File

@ -3,7 +3,7 @@ import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateCol
@Entity('user_refresh_tokens')
export class UserRefreshToken {
@PrimaryGeneratedColumn('uuid')
id: string;
refresh_token: string;
@Index()
@Column({
@ -19,10 +19,22 @@ export class UserRefreshToken {
@Column({
nullable: true,
length: 64
length: 128
})
os: string;
@Column({
nullable: true,
length: 256
})
device: string;
@Column({
nullable: true,
length: 64
})
platform: string;
@Column({
nullable: true,
length: 64
@ -35,6 +47,9 @@ export class UserRefreshToken {
})
remote_addr: string;
@Column('timestamp')
expired_at: Date;
@Column()
@CreateDateColumn()
created_at: Date;

View File

@ -1,7 +1,6 @@
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')
@ -38,10 +37,9 @@ export class User {
@Column({
nullable: false,
default: 'STAFF' as Role,
length: 30,
type: 'uuid'
})
role: Role;
id_role: string;
@Column({
nullable: false,

41
src/entity/users_roles.ts Normal file
View File

@ -0,0 +1,41 @@
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn } from 'typeorm';
import { Status } from '../types/status';
import { RoleList } from '../types/role';
@Entity('user_roles')
export class UserRole {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({
nullable: false,
unique: true,
length: 128
})
name: string;
@Column({
nullable: false,
type: 'jsonb'
})
roles: RoleList[];
@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;
}