Merge pull request #3560 from StarryKira/feat/issue-3557-oauth-email

feat: fix OAuth email completion flow
This commit is contained in:
Wesley Liddick
2026-06-30 10:55:00 +08:00
committed by GitHub
7 changed files with 177 additions and 9 deletions
@@ -152,6 +152,7 @@ import { useRoute, useRouter } from 'vue-router'
import { useClipboard } from '@/composables/useClipboard'
import { useAppStore, useAuthStore } from '@/stores'
import { apiClient } from '@/api/client'
import { buildApiUrl } from '@/api/url'
import {
exchangePendingOAuthCompletion,
persistOAuthTokenContext,
@@ -256,8 +257,6 @@ function readPendingEmailOAuthProvider(): 'github' | 'google' | null {
function redirectProviderCallbackToBackend(provider: 'github' | 'google'): void {
if (typeof window === 'undefined') return
const apiBase = (import.meta.env.VITE_API_BASE_URL as string | undefined) || '/api/v1'
const normalized = apiBase.replace(/\/$/, '')
const params = new URLSearchParams()
for (const [key, value] of Object.entries(route.query)) {
if (Array.isArray(value)) {
@@ -269,7 +268,7 @@ function redirectProviderCallbackToBackend(provider: 'github' | 'google'): void
}
}
const suffix = params.toString() ? `?${params.toString()}` : ''
window.location.href = `${normalized}/auth/oauth/${provider}/callback${suffix}`
window.location.href = buildApiUrl(`/auth/oauth/${provider}/callback${suffix}`)
}
async function finalizeTokenResponse(tokenResponse: OAuthTokenResponse, redirect: string) {