user.entity.ts 880 B

12345678910111213141516171819202122232425262728293031323334
  1. import { DeepPartial, HasCustomFields } from 'shared/shared-types';
  2. import { Column, Entity, JoinTable, ManyToMany } from 'typeorm';
  3. import { VendureEntity } from '../base/base.entity';
  4. import { CustomUserFields } from '../custom-entity-fields';
  5. import { Role } from '../role/role.entity';
  6. @Entity()
  7. export class User extends VendureEntity implements HasCustomFields {
  8. constructor(input?: DeepPartial<User>) {
  9. super(input);
  10. }
  11. @Column({ unique: true })
  12. identifier: string;
  13. @Column() passwordHash: string;
  14. @Column({ default: false })
  15. verified: boolean;
  16. @Column({ type: 'varchar', nullable: true })
  17. verificationToken: string | null;
  18. @ManyToMany(type => Role)
  19. @JoinTable()
  20. roles: Role[];
  21. @Column({ nullable: true })
  22. lastLogin: string;
  23. @Column(type => CustomUserFields)
  24. customFields: CustomUserFields;
  25. }