diff options
Diffstat (limited to 'server/lib/auth/oauth-model.ts')
-rw-r--r-- | server/lib/auth/oauth-model.ts | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/server/lib/auth/oauth-model.ts b/server/lib/auth/oauth-model.ts index 322b69e3a..603cc0f5f 100644 --- a/server/lib/auth/oauth-model.ts +++ b/server/lib/auth/oauth-model.ts | |||
@@ -5,7 +5,6 @@ import { MOAuthClient } from '@server/types/models' | |||
5 | import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token' | 5 | import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token' |
6 | import { MUser } from '@server/types/models/user/user' | 6 | import { MUser } from '@server/types/models/user/user' |
7 | import { pick } from '@shared/core-utils' | 7 | import { pick } from '@shared/core-utils' |
8 | import { UserRole } from '@shared/models/users/user-role' | ||
9 | import { logger } from '../../helpers/logger' | 8 | import { logger } from '../../helpers/logger' |
10 | import { CONFIG } from '../../initializers/config' | 9 | import { CONFIG } from '../../initializers/config' |
11 | import { OAuthClientModel } from '../../models/oauth/oauth-client' | 10 | import { OAuthClientModel } from '../../models/oauth/oauth-client' |
@@ -13,6 +12,7 @@ import { OAuthTokenModel } from '../../models/oauth/oauth-token' | |||
13 | import { UserModel } from '../../models/user/user' | 12 | import { UserModel } from '../../models/user/user' |
14 | import { findAvailableLocalActorName } from '../local-actor' | 13 | import { findAvailableLocalActorName } from '../local-actor' |
15 | import { buildUser, createUserAccountAndChannelAndPlaylist } from '../user' | 14 | import { buildUser, createUserAccountAndChannelAndPlaylist } from '../user' |
15 | import { ExternalUser } from './external-auth' | ||
16 | import { TokensCache } from './tokens-cache' | 16 | import { TokensCache } from './tokens-cache' |
17 | 17 | ||
18 | type TokenInfo = { | 18 | type TokenInfo = { |
@@ -26,12 +26,7 @@ export type BypassLogin = { | |||
26 | bypass: boolean | 26 | bypass: boolean |
27 | pluginName: string | 27 | pluginName: string |
28 | authName?: string | 28 | authName?: string |
29 | user: { | 29 | user: ExternalUser |
30 | username: string | ||
31 | email: string | ||
32 | displayName: string | ||
33 | role: UserRole | ||
34 | } | ||
35 | } | 30 | } |
36 | 31 | ||
37 | async function getAccessToken (bearerToken: string) { | 32 | async function getAccessToken (bearerToken: string) { |
@@ -219,16 +214,11 @@ export { | |||
219 | 214 | ||
220 | // --------------------------------------------------------------------------- | 215 | // --------------------------------------------------------------------------- |
221 | 216 | ||
222 | async function createUserFromExternal (pluginAuth: string, options: { | 217 | async function createUserFromExternal (pluginAuth: string, userOptions: ExternalUser) { |
223 | username: string | 218 | const username = await findAvailableLocalActorName(userOptions.username) |
224 | email: string | ||
225 | role: UserRole | ||
226 | displayName: string | ||
227 | }) { | ||
228 | const username = await findAvailableLocalActorName(options.username) | ||
229 | 219 | ||
230 | const userToCreate = buildUser({ | 220 | const userToCreate = buildUser({ |
231 | ...pick(options, [ 'email', 'role' ]), | 221 | ...pick(userOptions, [ 'email', 'role', 'adminFlags', 'videoQuota', 'videoQuotaDaily' ]), |
232 | 222 | ||
233 | username, | 223 | username, |
234 | emailVerified: null, | 224 | emailVerified: null, |
@@ -238,7 +228,7 @@ async function createUserFromExternal (pluginAuth: string, options: { | |||
238 | 228 | ||
239 | const { user } = await createUserAccountAndChannelAndPlaylist({ | 229 | const { user } = await createUserAccountAndChannelAndPlaylist({ |
240 | userToCreate, | 230 | userToCreate, |
241 | userDisplayName: options.displayName | 231 | userDisplayName: userOptions.displayName |
242 | }) | 232 | }) |
243 | 233 | ||
244 | return user | 234 | return user |