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'
// 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)
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
password: null,
email: options.email,
nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY,
- p2pEnabled: CONFIG.DEFAULTS.P2P.ENABLED,
+ p2pEnabled: CONFIG.DEFAULTS.P2P.WEBAPP.ENABLED,
autoPlayVideo: true,
role: options.role,
videoQuota: CONFIG.USER.VIDEO_QUOTA,