// Copyright IBM Corp. 2020. All Rights Reserved. // Node module: @loopback/authentication-jwt // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT import {Entity, hasOne, model, property} from '@loopback/repository'; import {UserCredentials} from './user-credentials.model'; type Phone = { countryCode: string; number: string } @model({ settings: { strict: false, }, }) export class User extends Entity { // must keep it // add id:string @property({ type: 'string', id: true, generated: false, defaultFn: 'uuidv4', }) id: string; @property({ type: 'string', }) tenantId: string; // must keep it @property({ type: 'string', required: true, index: { unique: true, }, }) username: string; // must keep it // feat email unique @property({ type: 'string', required: true, index: { unique: true, }, }) email: string; @property({ type: 'string', }) fullName?: boolean; @property({ type: 'object', }) phone?: Phone; @property({ type: 'string', }) bio?: boolean; @property({ type: 'boolean', }) emailVerified?: boolean; @property({ type: 'boolean', }) phoneVerified?: boolean; @property({ type: 'string', }) emailVerificationToken?: string; @property({ type: 'string', }) phoneVerificationToken?: string; @property({ type: 'string', }) avatar?: string; @hasOne(() => UserCredentials) userCredentials: UserCredentials; @property({ type: 'date', default: () => new Date(), }) lastLoginAt?: Date; @property({ type: 'date', default: () => new Date(), }) createdAt?: Date; @property({ type: 'date', default: () => new Date(), }) updatedAt?: Date; // Define well-known properties here // Indexer property to allow additional data // eslint-disable-next-line @typescript-eslint/no-explicit-any [prop: string]: any; constructor(data?: Partial) { super(data); } } export interface UserRelations { // describe navigational properties here } export type UserWithRelations = User & UserRelations;