fix: 修复邮箱快捷登录前端回调兜底

This commit is contained in:
lyen1688
2026-05-06 19:44:45 +08:00
committed by lyen1688
parent 480fe27b31
commit 7f185422a5
4 changed files with 69 additions and 1 deletions

View File

@@ -34,6 +34,7 @@ import GoogleMark from './GoogleMark.vue'
import { resolveAffiliateReferralCode, storeOAuthAffiliateCode } from '@/utils/oauthAffiliate'
type EmailOAuthProvider = 'github' | 'google'
const EMAIL_OAUTH_PENDING_PROVIDER_KEY = 'email_oauth_pending_provider'
const props = withDefaults(defineProps<{
disabled?: boolean
@@ -73,6 +74,7 @@ function startLogin(provider: EmailOAuthProvider): void {
const redirectTo = (route.query.redirect as string) || '/dashboard'
const affiliateCode = resolveAffiliateReferralCode(props.affCode, route.query.aff, route.query.aff_code)
storeOAuthAffiliateCode(affiliateCode)
window.sessionStorage.setItem(EMAIL_OAUTH_PENDING_PROVIDER_KEY, provider)
const apiBase = (import.meta.env.VITE_API_BASE_URL as string | undefined) || '/api/v1'
const normalized = apiBase.replace(/\/$/, '')
const params = new URLSearchParams({ redirect: redirectTo })

View File

@@ -57,6 +57,7 @@ describe('EmailOAuthButtons', () => {
'/api/v1/auth/oauth/github/start?redirect=%2Fbilling%3Fplan%3Dpro&aff_code=AFF123'
)
expect(window.sessionStorage.getItem('oauth_aff_code')).toBe('AFF123')
expect(window.sessionStorage.getItem('email_oauth_pending_provider')).toBe('github')
})
it('uses a full-width descriptive button when only GitHub is enabled', () => {