<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" required
formControlName="username" [ngClass]="{ 'input-error': formErrors['username'] }"
>
<div *ngIf="formErrors.username" class="form-error">
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 null
const passwordMatch = await user.isPasswordMatch(password)
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,
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 } ]
})
it('Should fail with a registered user having too many video', async function () {
- this.timeout(10000)
+ this.timeout(15000)
const user = {
username: 'user3',