fix pending auth session restore

This commit is contained in:
IanShaw027
2026-04-21 01:05:59 +08:00
parent ea27ac6fd7
commit a70f7aca07
2 changed files with 44 additions and 9 deletions

View File

@@ -261,6 +261,35 @@ describe('useAuthStore', () => {
expect(localStorage.getItem('pending_auth_session')).toBeNull()
})
it('restores a persisted pending oauth session without requiring a token value', () => {
const firstStore = useAuthStore()
firstStore.setPendingAuthSession({
token: '',
token_field: 'pending_oauth_token',
provider: 'oidc',
redirect: '/welcome',
adoption_required: true,
suggested_display_name: 'OIDC Nick'
})
setActivePinia(createPinia())
const restoredStore = useAuthStore()
restoredStore.checkAuth()
expect(restoredStore.isAuthenticated).toBe(false)
expect(restoredStore.hasPendingAuthSession).toBe(true)
expect(restoredStore.pendingAuthSession).toEqual({
token: '',
token_field: 'pending_oauth_token',
provider: 'oidc',
redirect: '/welcome',
adoption_required: true,
suggested_display_name: 'OIDC Nick',
suggested_avatar_url: undefined
})
})
it('preserves pending auth session when registration fails', async () => {
const store = useAuthStore()
store.setPendingAuthSession({