chore(server): convert User model to TypeORM entity (#2499)
* chore: convert basic RefreshToken model to TypeORM entity Co-authored-by: v1b3m <vibenjamin6@gmail.com> * Fix import Co-authored-by: v1b3m <vibenjamin6@gmail.com> * Refactor according to review Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com> * Refactor according to review Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com> * Refactor according to review Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com> --------- Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com>
This commit is contained in:
93
server/src/coreV2/user/user.entity.ts
Normal file
93
server/src/coreV2/user/user.entity.ts
Normal file
@ -0,0 +1,93 @@
|
||||
import { ID, Field, ObjectType } from '@nestjs/graphql';
|
||||
|
||||
import {
|
||||
Entity,
|
||||
Column,
|
||||
PrimaryGeneratedColumn,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
OneToMany,
|
||||
} from 'typeorm';
|
||||
import { IDField } from '@ptc-org/nestjs-query-graphql';
|
||||
import { GraphQLJSONObject } from 'graphql-type-json';
|
||||
|
||||
import { RefreshToken } from 'src/coreV2/refresh-token/refresh-token.entity';
|
||||
|
||||
@Entity('users')
|
||||
@ObjectType('user')
|
||||
// @Authorize({
|
||||
// authorize: (context: any) => ({
|
||||
// // FIXME: We do not have this relation in the database
|
||||
// workspaceMember: {
|
||||
// workspaceId: { eq: context?.req?.user?.workspace?.id },
|
||||
// },
|
||||
// }),
|
||||
// })
|
||||
export class User {
|
||||
@IDField(() => ID)
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Field()
|
||||
@Column({ nullable: true })
|
||||
firstName: string;
|
||||
|
||||
@Field()
|
||||
@Column({ nullable: true })
|
||||
lastName: string;
|
||||
|
||||
@Field()
|
||||
@Column()
|
||||
email: string;
|
||||
|
||||
@Field()
|
||||
@Column({ default: false })
|
||||
emailVerified: boolean;
|
||||
|
||||
@Field()
|
||||
@Column({ nullable: true })
|
||||
avatarUrl: string;
|
||||
|
||||
@Field()
|
||||
@Column()
|
||||
locale: string;
|
||||
|
||||
@Field({ nullable: true })
|
||||
@Column({ nullable: true })
|
||||
phoneNumber: string;
|
||||
|
||||
@Field({ nullable: true })
|
||||
@Column({ nullable: true })
|
||||
lastSeen: Date;
|
||||
|
||||
@Field({ nullable: true })
|
||||
@Column({ default: false })
|
||||
disabled: boolean;
|
||||
|
||||
@Field({ nullable: true })
|
||||
@Column({ nullable: true })
|
||||
passwordHash: string;
|
||||
|
||||
@Field(() => GraphQLJSONObject, { nullable: true })
|
||||
@Column({ type: 'json', nullable: true })
|
||||
metadata: Record<string, any>;
|
||||
|
||||
@Field()
|
||||
@Column({ default: false })
|
||||
canImpersonate: boolean;
|
||||
|
||||
@Field()
|
||||
@CreateDateColumn({ type: 'timestamp with time zone' })
|
||||
createdAt: Date;
|
||||
|
||||
@Field()
|
||||
@UpdateDateColumn({ type: 'timestamp with time zone' })
|
||||
updatedAt: Date;
|
||||
|
||||
@Field({ nullable: true })
|
||||
@Column({ nullable: true })
|
||||
deletedAt: Date;
|
||||
|
||||
@OneToMany(() => RefreshToken, (refreshToken) => refreshToken.user)
|
||||
refreshTokens: RefreshToken[];
|
||||
}
|
||||
Reference in New Issue
Block a user