fix: 修复邮箱快捷登录前端回调兜底
This commit is contained in:
@@ -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 })
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user