From ba12e8b3a6de8ac82101894abe7460b392fec42a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 29 Jan 2018 16:09:50 +0100 Subject: Add ability to login with email --- server/models/account/user.ts | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'server/models/account') diff --git a/server/models/account/user.ts b/server/models/account/user.ts index 8eb88062a..809e821bd 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts @@ -121,17 +121,6 @@ export class UserModel extends Model { return this.count() } - static getByUsername (username: string) { - const query = { - where: { - username: username - }, - include: [ { model: AccountModel, required: true } ] - } - - return UserModel.findOne(query) - } - static listForApi (start: number, count: number, sort: string) { const query = { offset: start, @@ -172,7 +161,9 @@ export class UserModel extends Model { return UserModel.scope('withVideoChannel').findOne(query) } - static loadByUsernameOrEmail (username: string, email: string) { + static loadByUsernameOrEmail (username: string, email?: string) { + if (!email) email = username + const query = { where: { [ Sequelize.Op.or ]: [ { username }, { email } ] -- cgit v1.2.3