From 2570fd9c1c879d1a543fb0dff1e7cfb036234d11 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 4 Jan 2023 11:41:03 +0100 Subject: Redirect to default login url on 401 Can be an external URL --- client/src/root-helpers/plugins-manager.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'client/src/root-helpers') 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) { -- cgit v1.2.3