mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-27 02:04:09 +00:00
Feat/workspaces 5 auth gate check (#8350)
## Summary - Fix auth related race conditions with a new WorkspaceAuthGate in App.vue - De dup initialization calls - Add state machine to track state of refreshRemoteConfig - Fix websocket not using new workspace jwt - Misc improvments ## Changes - **What**: Mainly WorkspaceAuthGate.vue - **Breaking**: <!-- Any breaking changes (if none, remove this line) --> - **Dependencies**: <!-- New dependencies (if none, remove this line) --> ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8350-Feat-workspaces-5-auth-gate-check-2f66d73d365081b1a49afcd418fab3e7) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { api } from '@/scripts/api'
|
||||
|
||||
import { remoteConfig } from './remoteConfig'
|
||||
import { remoteConfig, remoteConfigState } from './remoteConfig'
|
||||
|
||||
interface RefreshRemoteConfigOptions {
|
||||
/**
|
||||
@@ -12,7 +12,12 @@ interface RefreshRemoteConfigOptions {
|
||||
|
||||
/**
|
||||
* Loads remote configuration from the backend /features endpoint
|
||||
* and updates the reactive remoteConfig ref
|
||||
* and updates the reactive remoteConfig ref.
|
||||
*
|
||||
* Sets remoteConfigState to:
|
||||
* - 'anonymous' when loaded without auth
|
||||
* - 'authenticated' when loaded with auth
|
||||
* - 'error' when load fails
|
||||
*/
|
||||
export async function refreshRemoteConfig(
|
||||
options: RefreshRemoteConfigOptions = {}
|
||||
@@ -28,6 +33,7 @@ export async function refreshRemoteConfig(
|
||||
const config = await response.json()
|
||||
window.__CONFIG__ = config
|
||||
remoteConfig.value = config
|
||||
remoteConfigState.value = useAuth ? 'authenticated' : 'anonymous'
|
||||
return
|
||||
}
|
||||
|
||||
@@ -35,10 +41,12 @@ export async function refreshRemoteConfig(
|
||||
if (response.status === 401 || response.status === 403) {
|
||||
window.__CONFIG__ = {}
|
||||
remoteConfig.value = {}
|
||||
remoteConfigState.value = 'error'
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch remote config:', error)
|
||||
window.__CONFIG__ = {}
|
||||
remoteConfig.value = {}
|
||||
remoteConfigState.value = 'error'
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user