Add ability to login with email
[oweals/peertube.git] / server / lib / oauth-model.ts
index b3cc75590724775fbb57245f1bb78bf146f61d32..3adcce7b0e1d4f25c01c784b2041c2340dcec364 100644 (file)
@@ -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 null
 
   const passwordMatch = await user.isPasswordMatch(password)