import type { TFunction } from 'i18next'; import type { IAbstractModel, IAbstractModelMethods } from '../modules/AbstractModel.ts'; import AbstractModel from '../modules/AbstractModel.ts'; import type { IApp } from '../server.ts'; interface IUser { avatar: string; name: { first: string; last: string; nick: string; }; password: string; email: string; sessionTokens: { token: string; valid: Date; }[]; verificationTokens: { until: Date; token: string; }[]; passwordRecoveryTokens: { until: Date; token: string; }[]; permissions: string[]; roles: string[]; isVerified: boolean; locale: string; languages: string[]; id?: string; } interface IStatic extends IAbstractModel> { getUserByEmailAndPassword(email: string, password: string): Promise | false>; hashPassword(password: string): Promise; getUserByToken(token: string): Promise | false>; getUserByEmail(email: string): Promise | false>; getUserByPasswordRecoveryToken(token: string): Promise | false>; generateUserPasswordRecoveryToken(user: InstanceType): Promise<{ token: string; until: Date; }>; getUserByVerificationToken(token: string): Promise | false>; generateUserVerificationToken(user: InstanceType): Promise<{ token: string; until: Date; }>; } /** * @deprecated use User Model instead of UserOld */ declare class UserOld extends AbstractModel, IStatic> { constructor(app: IApp); initHooks(): void; get modelSchema(): { avatar: { type: StringConstructor; maxlength: number; }; name: { first: { type: StringConstructor; maxlength: number; }; last: { type: StringConstructor; maxlength: number; }; nick: { minlength: number; maxlength: number; type: StringConstructor; index: { unique: boolean; partialFilterExpression: { 'name.nick': { $type: string; }; }; }; }; }; password: StringConstructor; email: { type: StringConstructor; maxlength: number; index: { unique: boolean; partialFilterExpression: { email: { $type: string; }; }; }; }; sessionTokens: { token: StringConstructor; valid: DateConstructor; }[]; verificationTokens: { until: DateConstructor; token: StringConstructor; }[]; passwordRecoveryTokens: { until: DateConstructor; token: StringConstructor; }[]; permissions: never[]; roles: never[]; isVerified: { type: BooleanConstructor; default: boolean; }; locale: { type: StringConstructor; default: string; }; languages: StringConstructor[]; }; static getUserByEmailAndPassword(this: UserOld['mongooseModel'], email: string, password: string): Promise & Omit & IAbstractModelMethods)>; generateToken(this: InstanceType): Promise<{ token: string; valid: Date; }>; getPublic(this: InstanceType): { avatar: string; name: { first: string; last: string; nick: string; }; email: string; id: string | undefined; isVerified: boolean; permissions: string[]; locale: string; }; static hashPassword(this: UserOld['mongooseModel'], password: string): Promise; static getUserByToken(this: UserOld['mongooseModel'], token: string): Promise & Omit & IAbstractModelMethods)>; static getUserByEmail(this: UserOld['mongooseModel'], email: string): Promise & Omit & IAbstractModelMethods)>; static generateUserPasswordRecoveryToken(userMongoose: InstanceType): Promise<{ token: string; until: number; }>; static getUserByPasswordRecoveryToken(this: UserOld['mongooseModel'], passwordRecoveryToken: string): Promise & Omit & IAbstractModelMethods>; sendPasswordRecoveryEmail(this: InstanceType, i18n: { t: TFunction; language: string; }): Promise; static generateUserVerificationToken(userMongoose: InstanceType): Promise<{ token: string; until: number; }>; static getUserByVerificationToken(this: UserOld['mongooseModel'], verificationToken: string): Promise & Omit & IAbstractModelMethods>; sendVerificationEmail(this: InstanceType, i18n: { t: TFunction; language: string; }): Promise; } export default UserOld;