Yield generated for aefb9fc2-2ae0-44db-bd58-7fb041b08d16
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.
 
 
 
 

33 lines
769 B

import { DbAuditModel } from '../../utils/dbmodel.model';
import { Column, Entity, JoinTable, ManyToMany } from 'typeorm';
import { ApiModelProperty } from '@nestjs/swagger';
import { Exclude } from 'class-transformer';
import { Role } from '../roles/roles.entity';
import { ADMIN_ROLE } from '../roles/roles.constants';
@Entity()
export class User extends DbAuditModel {
@Column()
@ApiModelProperty({ example: 'foo@bar.fr' })
email: string;
@Column()
@ApiModelProperty()
firstName: string;
@Column()
@ApiModelProperty()
lastName: string;
@Column()
@Exclude()
password: string;
@ManyToMany(type => Role)
@JoinTable()
roles: Role[];
isAdmin(): boolean {
return !!(this.roles || []).find(role => role.name === ADMIN_ROLE);
}
}