diff options
Diffstat (limited to 'server/lib/auth')
-rw-r--r-- | server/lib/auth/oauth-model.ts | 9 |
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 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import { AccessDeniedError } from '@node-oauth/oauth2-server' | 2 | import { AccessDeniedError } from '@node-oauth/oauth2-server' |
3 | import { PluginManager } from '@server/lib/plugins/plugin-manager' | 3 | import { PluginManager } from '@server/lib/plugins/plugin-manager' |
4 | import { ActorModel } from '@server/models/actor/actor' | ||
5 | import { MOAuthClient } from '@server/types/models' | 4 | import { MOAuthClient } from '@server/types/models' |
6 | import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token' | 5 | import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token' |
7 | import { MUser } from '@server/types/models/user/user' | 6 | import { MUser } from '@server/types/models/user/user' |
@@ -12,6 +11,7 @@ import { CONFIG } from '../../initializers/config' | |||
12 | import { OAuthClientModel } from '../../models/oauth/oauth-client' | 11 | import { OAuthClientModel } from '../../models/oauth/oauth-client' |
13 | import { OAuthTokenModel } from '../../models/oauth/oauth-token' | 12 | import { OAuthTokenModel } from '../../models/oauth/oauth-token' |
14 | import { UserModel } from '../../models/user/user' | 13 | import { UserModel } from '../../models/user/user' |
14 | import { findAvailableLocalActorName } from '../local-actor' | ||
15 | import { buildUser, createUserAccountAndChannelAndPlaylist } from '../user' | 15 | import { buildUser, createUserAccountAndChannelAndPlaylist } from '../user' |
16 | import { TokensCache } from './tokens-cache' | 16 | import { 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 |