aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/auth
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/auth')
-rw-r--r--server/lib/auth/oauth-model.ts20
1 files changed, 7 insertions, 13 deletions
diff --git a/server/lib/auth/oauth-model.ts b/server/lib/auth/oauth-model.ts
index 5d68f44e9..910fdeec1 100644
--- a/server/lib/auth/oauth-model.ts
+++ b/server/lib/auth/oauth-model.ts
@@ -5,14 +5,14 @@ import { ActorModel } from '@server/models/actor/actor'
5import { MOAuthClient } from '@server/types/models' 5import { MOAuthClient } from '@server/types/models'
6import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token' 6import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token'
7import { MUser } from '@server/types/models/user/user' 7import { MUser } from '@server/types/models/user/user'
8import { UserAdminFlag } from '@shared/models/users/user-flag.model' 8import { pick } from '@shared/core-utils'
9import { UserRole } from '@shared/models/users/user-role' 9import { UserRole } from '@shared/models/users/user-role'
10import { logger } from '../../helpers/logger' 10import { logger } from '../../helpers/logger'
11import { CONFIG } from '../../initializers/config' 11import { CONFIG } from '../../initializers/config'
12import { OAuthClientModel } from '../../models/oauth/oauth-client' 12import { OAuthClientModel } from '../../models/oauth/oauth-client'
13import { OAuthTokenModel } from '../../models/oauth/oauth-token' 13import { OAuthTokenModel } from '../../models/oauth/oauth-token'
14import { UserModel } from '../../models/user/user' 14import { UserModel } from '../../models/user/user'
15import { createUserAccountAndChannelAndPlaylist } from '../user' 15import { buildUser, createUserAccountAndChannelAndPlaylist } from '../user'
16import { TokensCache } from './tokens-cache' 16import { TokensCache } from './tokens-cache'
17 17
18type TokenInfo = { 18type TokenInfo = {
@@ -229,19 +229,13 @@ async function createUserFromExternal (pluginAuth: string, options: {
229 const actor = await ActorModel.loadLocalByName(options.username) 229 const actor = await ActorModel.loadLocalByName(options.username)
230 if (actor) return null 230 if (actor) return null
231 231
232 const userToCreate = new UserModel({ 232 const userToCreate = buildUser({
233 username: options.username, 233 ...pick(options, [ 'username', 'email', 'role' ]),
234
235 emailVerified: null,
234 password: null, 236 password: null,
235 email: options.email,
236 nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY,
237 p2pEnabled: CONFIG.DEFAULTS.P2P.WEBAPP.ENABLED,
238 autoPlayVideo: true,
239 role: options.role,
240 videoQuota: CONFIG.USER.VIDEO_QUOTA,
241 videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY,
242 adminFlags: UserAdminFlag.NONE,
243 pluginAuth 237 pluginAuth
244 }) as MUser 238 })
245 239
246 const { user } = await createUserAccountAndChannelAndPlaylist({ 240 const { user } = await createUserAccountAndChannelAndPlaylist({
247 userToCreate, 241 userToCreate,