]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/auth/oauth-model.ts
Fix client html performance regression
[github/Chocobozzz/PeerTube.git] / server / lib / auth / oauth-model.ts
index b68cce6d232b4d2c2cdaf1616a6731051f349766..5d68f44e9c50a4e6dc62725dbd25f012601451f8 100644 (file)
@@ -9,9 +9,9 @@ import { UserAdminFlag } from '@shared/models/users/user-flag.model'
 import { UserRole } from '@shared/models/users/user-role'
 import { logger } from '../../helpers/logger'
 import { CONFIG } from '../../initializers/config'
-import { UserModel } from '../../models/user/user'
 import { OAuthClientModel } from '../../models/oauth/oauth-client'
 import { OAuthTokenModel } from '../../models/oauth/oauth-token'
+import { UserModel } from '../../models/user/user'
 import { createUserAccountAndChannelAndPlaylist } from '../user'
 import { TokensCache } from './tokens-cache'
 
@@ -98,7 +98,14 @@ async function getUser (usernameOrEmail?: string, password?: string, bypassLogin
     // Then we just go through a regular login process
     if (user.pluginAuth !== null) {
       // This user does not belong to this plugin, skip it
-      if (user.pluginAuth !== bypassLogin.pluginName) return null
+      if (user.pluginAuth !== bypassLogin.pluginName) {
+        logger.info(
+          'Cannot bypass oauth login by plugin %s because %s has another plugin auth method (%s).',
+          bypassLogin.pluginName, bypassLogin.user.email, user.pluginAuth
+        )
+
+        return null
+      }
 
       checkUserValidityOrThrow(user)
 
@@ -109,6 +116,7 @@ async function getUser (usernameOrEmail?: string, password?: string, bypassLogin
   logger.debug('Getting User (username/email: ' + usernameOrEmail + ', password: ******).')
 
   const user = await UserModel.loadByUsernameOrEmail(usernameOrEmail)
+
   // If we don't find the user, or if the user belongs to a plugin
   if (!user || user.pluginAuth !== null || !password) return null