You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
562 B

import "reflect-metadata"
import { Field, ObjectType } from "type-graphql"
import { BaseEntity, BeforeInsert, Column, Entity, PrimaryGeneratedColumn } from "typeorm"
import * as argon2 from "../utils/argon2"
@ObjectType()
@Entity()
export class User extends BaseEntity {
@PrimaryGeneratedColumn()
id!: number
@Field()
@Column()
email: string = ""
@Column()
password: string = ""
@BeforeInsert()
async hashPassword() {
this.password = await argon2.hashIncludingOptions(this.password)
}
}