mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-23 15:59:47 +00:00
[backport rh-test] Add session cookie auth (#6299)
## Summary Backport of session cookie authentication implementation from main to rh-test. ## Changes - Added session cookie management via extension hooks - Cookie created on login, refreshed on token refresh, deleted on logout - New extension hooks: `onAuthTokenRefreshed()` and `onAuthUserLogout()` - DDD-compliant structure with platform layer (`src/platform/auth/session/`) ## Conflict Resolution - Resolved import conflict in `firebaseAuthStore.ts` (merged `onIdTokenChanged` + `sendEmailVerification`) - Added `onIdTokenChanged` mock to tests ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6299-backport-rh-test-Add-session-cookie-auth-2986d73d365081238507f99ae789d44b) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { whenever } from '@vueuse/core'
|
||||
import { computed } from 'vue'
|
||||
import { computed, watch } from 'vue'
|
||||
|
||||
import { useFirebaseAuthActions } from '@/composables/auth/useFirebaseAuthActions'
|
||||
import { t } from '@/i18n'
|
||||
@@ -37,6 +37,15 @@ export const useCurrentUser = () => {
|
||||
const onUserResolved = (callback: (user: AuthUserInfo) => void) =>
|
||||
whenever(resolvedUserInfo, callback, { immediate: true })
|
||||
|
||||
const onTokenRefreshed = (callback: () => void) =>
|
||||
whenever(() => authStore.tokenRefreshTrigger, callback)
|
||||
|
||||
const onUserLogout = (callback: () => void) => {
|
||||
watch(resolvedUserInfo, (user) => {
|
||||
if (!user) callback()
|
||||
})
|
||||
}
|
||||
|
||||
const userDisplayName = computed(() => {
|
||||
if (isApiKeyLogin.value) {
|
||||
return apiKeyStore.currentUser?.name
|
||||
@@ -133,6 +142,8 @@ export const useCurrentUser = () => {
|
||||
handleSignOut,
|
||||
handleSignIn,
|
||||
handleDeleteAccount,
|
||||
onUserResolved
|
||||
onUserResolved,
|
||||
onTokenRefreshed,
|
||||
onUserLogout
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user