ActivityPub-federated video streaming platform using P2P directly in your web browser
Add ability to login with email
Chocobozzzba12e8b3a6de
diff --git a/client/src/app/login/login.component.html b/client/src/app/login/login.component.htmlindex 24807987c6..a69acfcb1a 100644--- a/client/src/app/login/login.component.html+++ b/client/src/app/login/login.component.html@@ -7,9 +7,9 @@<form role="form" (ngSubmit)="login()" [formGroup]="form"><div class="form-group">- <label for="username">Username</label>+ <label for="username">Username or email address</label><input- type="text" id="username" placeholder="Username" required+ type="text" id="username" placeholder="Username or email address" requiredformControlName="username" [ngClass]="{ 'input-error': formErrors['username'] }"><div *ngIf="formErrors.username" class="form-error">diff --git a/server/lib/oauth-model.ts b/server/lib/oauth-model.tsindex b3cc755907..3adcce7b0e 100644--- a/server/lib/oauth-model.ts+++ b/server/lib/oauth-model.ts@@ -25,10 +25,10 @@ function getRefreshToken (refreshToken: string) {return OAuthTokenModel.getByRefreshTokenAndPopulateClient(refreshToken)}-async function getUser (username: string, password: string) {- logger.debug('Getting User (username: ' + username + ', password: ******).')+async function getUser (usernameOrEmail: string, password: string) {+ logger.debug('Getting User (username/email: ' + usernameOrEmail + ', password: ******).')- const user = await UserModel.getByUsername(username)+ const user = await UserModel.loadByUsernameOrEmail(usernameOrEmail)if (!user) return nullconst passwordMatch = await user.isPasswordMatch(password)diff --git a/server/models/account/user.ts b/server/models/account/user.tsindex 8eb88062ae..809e821bd3 100644--- a/server/models/account/user.ts+++ b/server/models/account/user.ts@@ -121,17 +121,6 @@ export class UserModel extends Model<UserModel> {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<UserModel> {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 } ]diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.tsindex 9938fe3a29..28fefe79fa 100644--- a/server/tests/api/check-params/users.ts+++ b/server/tests/api/check-params/users.ts@@ -523,7 +523,7 @@ describe('Test users API validators', function () {})it('Should fail with a registered user having too many video', async function () {- this.timeout(10000)+ this.timeout(15000)const user = {username: 'user3',