X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Froot-helpers%2Fplugins-manager.ts;h=f3416e44a09c5c2cac1d5ee7185eb15c4206e7fb;hb=ac24de4e7dce71067906d0b6858214c76bdbe026;hp=31510d4e644d22c8b4af65b0fc17493bbcc77da0;hpb=2e5dd0bef8797dad82e5a908c30bc126cb924033;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/root-helpers/plugins-manager.ts b/client/src/root-helpers/plugins-manager.ts index 31510d4e6..f3416e44a 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) {