X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Froot-helpers%2Fplugins-manager.ts;h=e5b06a94cbe3173ca9d713d2dc755ccead4ecc9b;hb=2570fd9c1c879d1a543fb0dff1e7cfb036234d11;hp=6c64e2b014167f3559a74d1180e265a8f2737c47;hpb=60b880acdfa85eab5c9ec09ba1283f82ae58ec85;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/root-helpers/plugins-manager.ts b/client/src/root-helpers/plugins-manager.ts index 6c64e2b01..e5b06a94c 100644 --- a/client/src/root-helpers/plugins-manager.ts +++ b/client/src/root-helpers/plugins-manager.ts @@ -3,7 +3,7 @@ import * as debug from 'debug' import { firstValueFrom, ReplaySubject } from 'rxjs' import { first, shareReplay } from 'rxjs/operators' import { RegisterClientHelpers } from 'src/types/register-client-option.model' -import { getHookType, internalRunHook } from '@shared/core-utils/plugins/hooks' +import { getExternalAuthHref, getHookType, internalRunHook } from '@shared/core-utils/plugins/hooks' import { ClientHookName, clientHookObject, @@ -16,7 +16,6 @@ import { RegisterClientRouteOptions, RegisterClientSettingsScriptOptions, RegisterClientVideoFieldOptions, - RegisteredExternalAuthConfig, ServerConfigPlugin } from '@shared/models' import { environment } from '../environments/environment' @@ -94,9 +93,13 @@ class PluginsManager { return isTheme ? '/themes' : '/plugins' } - static getExternalAuthHref (auth: RegisteredExternalAuthConfig) { - return environment.apiUrl + `/plugins/${auth.name}/${auth.version}/auth/${auth.authName}` + static getDefaultLoginHref (apiUrl: string, serverConfig: HTMLServerConfig) { + if (!serverConfig || serverConfig.client.menu.login.redirectOnSingleExternalAuth !== true) return undefined + const externalAuths = serverConfig.plugin.registeredExternalAuths + if (externalAuths.length !== 1) return undefined + + return getExternalAuthHref(apiUrl, externalAuths[0]) } loadPluginsList (config: HTMLServerConfig) {