(frontend) allow disabling silent login via a URL parameter

Several clients ran into issues with the silent login, leading to
redirections that were not appropriate for their use case.

Offer a URL parameter to control this behavior and disable silent
login when needed.
This commit is contained in:
lebaudantoine
2026-06-13 23:58:58 +02:00
committed by aleb_the_flash
parent ac85a20271
commit 70a296eea6
2 changed files with 22 additions and 2 deletions
+4
View File
@@ -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
+18 -2
View File
@@ -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],