[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:
Christian Byrne
2025-10-26 01:11:59 -07:00
committed by GitHub
parent 065b848e58
commit 072b234a13
8 changed files with 143 additions and 2 deletions

View File

@@ -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
}
}