X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fauth%2Foauth-model.ts;h=5d68f44e9c50a4e6dc62725dbd25f012601451f8;hb=f7ac03ee94d9d32e26bd712e8dc05a6109f5e835;hp=b9c69eb2db59f4b2fb7fd8dbc834ae2b8a889e34;hpb=dc48fdbe68e9dd3a3a6028181e61d8595d98e654;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/auth/oauth-model.ts b/server/lib/auth/oauth-model.ts index b9c69eb2d..5d68f44e9 100644 --- a/server/lib/auth/oauth-model.ts +++ b/server/lib/auth/oauth-model.ts @@ -1,7 +1,7 @@ -import * as express from 'express' +import express from 'express' import { AccessDeniedError } from 'oauth2-server' import { PluginManager } from '@server/lib/plugins/plugin-manager' -import { ActorModel } from '@server/models/activitypub/actor' +import { ActorModel } from '@server/models/actor/actor' import { MOAuthClient } from '@server/types/models' import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token' import { MUser } from '@server/types/models/user/user' @@ -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/account/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 @@ -226,6 +234,7 @@ async function createUserFromExternal (pluginAuth: string, options: { password: null, email: options.email, nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY, + p2pEnabled: CONFIG.DEFAULTS.P2P.WEBAPP.ENABLED, autoPlayVideo: true, role: options.role, videoQuota: CONFIG.USER.VIDEO_QUOTA,