46f0eb522f
* GH-3245 add passwordResetToken and passwordResetTokenExpiresAt column on user entity * Add password reset token expiry delay env variable * Add generatePasswordResetToken mutation resolver * Update .env.sample file on server * Add password reset token and expiry migration script * Add validate password reset token query and a dummy password update (WIP) resolver * Fix bug in password reset token generate * add update password mutation * Update name and add email password reset link * Add change password UI on settings page * Add reset password route on frontend * Add reset password form UI * sign in user on password reset * format code * make PASSWORD_RESET_TOKEN_EXPIRES_IN optional * add email template for password reset * Improve error message * Rename methods and DTO to improve naming * fix formatting of backend code * Update change password component * Update password reset via token component * update graphql files * spelling fix * Make password-reset route authless on frontend * show token generation wait time * remove constant from .env.example * Add PASSWORD_RESET_TOKEN_EXPIRES_IN in docs * refactor emails module in reset password * update Graphql generated file * update email template of password reset * add space between date and text * update method name * fix lint issues * remove unused code, fix indentation, and email link color * update test file for auth and token service * Fix ci: build twenty-emails when running tests --------- Co-authored-by: martmull <martmull@hotmail.fr>
87 lines
1.9 KiB
TypeScript
87 lines
1.9 KiB
TypeScript
import { ID, Field, ObjectType } from '@nestjs/graphql';
|
|
|
|
import {
|
|
Entity,
|
|
Column,
|
|
PrimaryGeneratedColumn,
|
|
CreateDateColumn,
|
|
UpdateDateColumn,
|
|
OneToMany,
|
|
ManyToOne,
|
|
} from 'typeorm';
|
|
import { IDField } from '@ptc-org/nestjs-query-graphql';
|
|
|
|
import { RefreshToken } from 'src/core/refresh-token/refresh-token.entity';
|
|
import { Workspace } from 'src/core/workspace/workspace.entity';
|
|
import { WorkspaceMember } from 'src/core/user/dtos/workspace-member.dto';
|
|
|
|
@Entity({ name: 'user', schema: 'core' })
|
|
@ObjectType('User')
|
|
export class User {
|
|
@IDField(() => ID)
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Field()
|
|
@Column({ default: '' })
|
|
firstName: string;
|
|
|
|
@Field()
|
|
@Column({ default: '' })
|
|
lastName: string;
|
|
|
|
@Field()
|
|
@Column()
|
|
email: string;
|
|
|
|
@Field()
|
|
@Column({ default: false })
|
|
emailVerified: boolean;
|
|
|
|
@Field({ nullable: true })
|
|
@Column({ default: false })
|
|
disabled: boolean;
|
|
|
|
@Field({ nullable: true })
|
|
@Column({ nullable: true })
|
|
passwordHash: string;
|
|
|
|
@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;
|
|
|
|
@Field(() => Workspace, { nullable: false })
|
|
@ManyToOne(() => Workspace, (workspace) => workspace.users, {
|
|
onDelete: 'SET NULL',
|
|
})
|
|
defaultWorkspace: Workspace;
|
|
|
|
@Field({ nullable: true })
|
|
@Column({ nullable: true })
|
|
passwordResetToken: string;
|
|
|
|
@Field({ nullable: true })
|
|
@Column({ nullable: true })
|
|
passwordResetTokenExpiresAt: Date;
|
|
|
|
@OneToMany(() => RefreshToken, (refreshToken) => refreshToken.user, {
|
|
cascade: true,
|
|
})
|
|
refreshTokens: RefreshToken[];
|
|
|
|
@Field(() => WorkspaceMember, { nullable: false })
|
|
workspaceMember: WorkspaceMember;
|
|
}
|