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
507 B
24 lines
507 B
5 years ago
|
import "reflect-metadata"
|
||
|
import { Field, ObjectType } from "type-graphql"
|
||
|
import { BaseEntity, BeforeInsert, Column, Entity, PrimaryGeneratedColumn } from "typeorm"
|
||
5 years ago
|
import { hashPassword } from "./auth"
|
||
5 years ago
|
|
||
|
@ObjectType()
|
||
5 years ago
|
@Entity()
|
||
|
export class User extends BaseEntity {
|
||
5 years ago
|
@PrimaryGeneratedColumn()
|
||
|
id!: number
|
||
5 years ago
|
|
||
5 years ago
|
@Field()
|
||
|
@Column()
|
||
|
email: string = ""
|
||
5 years ago
|
|
||
5 years ago
|
@Column()
|
||
|
password: string = ""
|
||
5 years ago
|
|
||
5 years ago
|
@BeforeInsert()
|
||
|
async hashPassword() {
|
||
|
this.password = await hashPassword(this.password)
|
||
|
}
|
||
5 years ago
|
}
|