aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/auth/oauth-model.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/auth/oauth-model.ts')
-rw-r--r--server/lib/auth/oauth-model.ts9
1 files changed, 4 insertions, 5 deletions
diff --git a/server/lib/auth/oauth-model.ts b/server/lib/auth/oauth-model.ts
index d9cf32827..322b69e3a 100644
--- a/server/lib/auth/oauth-model.ts
+++ b/server/lib/auth/oauth-model.ts
@@ -1,7 +1,6 @@
1import express from 'express' 1import express from 'express'
2import { AccessDeniedError } from '@node-oauth/oauth2-server' 2import { AccessDeniedError } from '@node-oauth/oauth2-server'
3import { PluginManager } from '@server/lib/plugins/plugin-manager' 3import { PluginManager } from '@server/lib/plugins/plugin-manager'
4import { ActorModel } from '@server/models/actor/actor'
5import { MOAuthClient } from '@server/types/models' 4import { MOAuthClient } from '@server/types/models'
6import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token' 5import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token'
7import { MUser } from '@server/types/models/user/user' 6import { MUser } from '@server/types/models/user/user'
@@ -12,6 +11,7 @@ import { CONFIG } from '../../initializers/config'
12import { OAuthClientModel } from '../../models/oauth/oauth-client' 11import { OAuthClientModel } from '../../models/oauth/oauth-client'
13import { OAuthTokenModel } from '../../models/oauth/oauth-token' 12import { OAuthTokenModel } from '../../models/oauth/oauth-token'
14import { UserModel } from '../../models/user/user' 13import { UserModel } from '../../models/user/user'
14import { findAvailableLocalActorName } from '../local-actor'
15import { buildUser, createUserAccountAndChannelAndPlaylist } from '../user' 15import { buildUser, createUserAccountAndChannelAndPlaylist } from '../user'
16import { TokensCache } from './tokens-cache' 16import { TokensCache } from './tokens-cache'
17 17
@@ -225,13 +225,12 @@ async function createUserFromExternal (pluginAuth: string, options: {
225 role: UserRole 225 role: UserRole
226 displayName: string 226 displayName: string
227}) { 227}) {
228 // Check an actor does not already exists with that name (removed user) 228 const username = await findAvailableLocalActorName(options.username)
229 const actor = await ActorModel.loadLocalByName(options.username)
230 if (actor) return null
231 229
232 const userToCreate = buildUser({ 230 const userToCreate = buildUser({
233 ...pick(options, [ 'username', 'email', 'role' ]), 231 ...pick(options, [ 'email', 'role' ]),
234 232
233 username,
235 emailVerified: null, 234 emailVerified: null,
236 password: null, 235 password: null,
237 pluginAuth 236 pluginAuth