diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e84cd7f..8e60f7d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to ## [Unreleased] +### Added + +- ✨(frontend) allow disabling silent login via a URL parameter + ### Changed - ✨(frontend) enhance noise reduction with BBBA audio processing pipeline diff --git a/src/frontend/src/features/auth/api/useUser.tsx b/src/frontend/src/features/auth/api/useUser.tsx index 3f4a72e0..7ff90791 100644 --- a/src/frontend/src/features/auth/api/useUser.tsx +++ b/src/frontend/src/features/auth/api/useUser.tsx @@ -5,6 +5,16 @@ import { type ApiUser } from './ApiUser' import { useMemo } from 'react' import { useConfig } from '@/api/useConfig' +const SILENT_LOGIN_PARAM = 'silentLogin' + +const isSilentLoginDisabledByUrl = () => { + if (typeof window === 'undefined') return false + const value = new URLSearchParams(window.location.search).get( + SILENT_LOGIN_PARAM + ) + return value === 'false' +} + /** * returns info about currently logged-in user * @@ -17,16 +27,22 @@ export const useUser = ( ) => { const { data, isLoading: isConfigLoading } = useConfig() + const disabledByUrl = useMemo(() => isSilentLoginDisabledByUrl(), []) + const options = useMemo(() => { if (isConfigLoading) return - if (data?.is_silent_login_enabled !== true) { + + const silentDisabled = + data?.is_silent_login_enabled !== true || disabledByUrl + + if (silentDisabled) { return { ...opts, attemptSilent: false, } } return opts.fetchUserOptions - }, [data, opts, isConfigLoading]) + }, [data, opts, isConfigLoading, disabledByUrl]) const query = useQuery({ queryKey: [keys.user],