mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
fix: Ensure logout clears both Firebase auth and API key (#5274)
* fix: Ensure logout clears both Firebase auth and API key When logging out via the avatar dropdown, the logout function was only clearing Firebase authentication but not the stored API key. This could leave users partially authenticated with their API key still active. Updated CurrentUserPopover to use handleSignOut from useCurrentUser composable, which properly handles both authentication methods: - Clears API key if logged in with API key - Signs out Firebase if logged in with Firebase This ensures complete logout regardless of authentication method. Fixes #5261 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * test: Update CurrentUserPopover tests to match new logout implementation Updated test mocks to include handleSignOut from useCurrentUser composable and adjusted test expectations to verify handleSignOut is called instead of the direct logout method. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -41,11 +41,13 @@ afterAll(() => {
|
||||
})
|
||||
|
||||
// Mock the useCurrentUser composable
|
||||
const mockHandleSignOut = vi.fn()
|
||||
vi.mock('@/composables/auth/useCurrentUser', () => ({
|
||||
useCurrentUser: vi.fn(() => ({
|
||||
userPhotoUrl: 'https://example.com/avatar.jpg',
|
||||
userDisplayName: 'Test User',
|
||||
userEmail: 'test@example.com'
|
||||
userEmail: 'test@example.com',
|
||||
handleSignOut: mockHandleSignOut
|
||||
}))
|
||||
}))
|
||||
|
||||
@@ -155,8 +157,8 @@ describe('CurrentUserPopover', () => {
|
||||
// Click the logout button
|
||||
await logoutButton.trigger('click')
|
||||
|
||||
// Verify logout was called
|
||||
expect(mockLogout).toHaveBeenCalled()
|
||||
// Verify handleSignOut was called
|
||||
expect(mockHandleSignOut).toHaveBeenCalled()
|
||||
|
||||
// Verify close event was emitted
|
||||
expect(wrapper.emitted('close')).toBeTruthy()
|
||||
|
||||
@@ -88,7 +88,8 @@ const emit = defineEmits<{
|
||||
close: []
|
||||
}>()
|
||||
|
||||
const { userDisplayName, userEmail, userPhotoUrl } = useCurrentUser()
|
||||
const { userDisplayName, userEmail, userPhotoUrl, handleSignOut } =
|
||||
useCurrentUser()
|
||||
const authActions = useFirebaseAuthActions()
|
||||
const dialogService = useDialogService()
|
||||
|
||||
@@ -103,7 +104,7 @@ const handleTopUp = () => {
|
||||
}
|
||||
|
||||
const handleLogout = async () => {
|
||||
await authActions.logout()
|
||||
await handleSignOut()
|
||||
emit('close')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user