fix(review): harden payment, oauth, and migration paths
This commit is contained in:
@@ -83,7 +83,8 @@ function simulateGuard(
|
||||
'/auth/callback',
|
||||
'/auth/linuxdo/callback',
|
||||
'/auth/oidc/callback',
|
||||
'/auth/wechat/callback'
|
||||
'/auth/wechat/callback',
|
||||
'/auth/wechat/payment/callback',
|
||||
]
|
||||
const pendingAuthPaths = ['/register', '/email-verify']
|
||||
const isAllowed =
|
||||
@@ -131,7 +132,8 @@ function simulateGuard(
|
||||
'/auth/callback',
|
||||
'/auth/linuxdo/callback',
|
||||
'/auth/oidc/callback',
|
||||
'/auth/wechat/callback'
|
||||
'/auth/wechat/callback',
|
||||
'/auth/wechat/payment/callback',
|
||||
]
|
||||
const pendingAuthPaths = ['/register', '/email-verify']
|
||||
const isAllowed =
|
||||
@@ -448,6 +450,18 @@ describe('路由守卫逻辑', () => {
|
||||
expect(redirect).toBeNull()
|
||||
})
|
||||
|
||||
it('unauthenticated: WeChat payment callback route is allowed', () => {
|
||||
const authState: MockAuthState = {
|
||||
isAuthenticated: false,
|
||||
isAdmin: false,
|
||||
isSimpleMode: false,
|
||||
backendModeEnabled: true,
|
||||
hasPendingAuthSession: false,
|
||||
}
|
||||
const redirect = simulateGuard('/auth/wechat/payment/callback', { requiresAuth: false }, authState)
|
||||
expect(redirect).toBeNull()
|
||||
})
|
||||
|
||||
it('unauthenticated: /register is allowed when a pending auth session exists', () => {
|
||||
const authState: MockAuthState = {
|
||||
isAuthenticated: false,
|
||||
|
||||
@@ -52,4 +52,13 @@ describe('router WeChat OAuth route', () => {
|
||||
expect(route?.meta.requiresAuth).toBe(false)
|
||||
expect(route?.meta.title).toBe('WeChat OAuth Callback')
|
||||
})
|
||||
|
||||
it('registers the WeChat payment callback route as a public route', async () => {
|
||||
const { default: router } = await import('@/router')
|
||||
const route = router.getRoutes().find((record) => record.name === 'WeChatPaymentOAuthCallback')
|
||||
|
||||
expect(route?.path).toBe('/auth/wechat/payment/callback')
|
||||
expect(route?.meta.requiresAuth).toBe(false)
|
||||
expect(route?.meta.title).toBe('WeChat Payment Callback')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -547,7 +547,8 @@ const BACKEND_MODE_CALLBACK_PATHS = [
|
||||
'/auth/callback',
|
||||
'/auth/linuxdo/callback',
|
||||
'/auth/oidc/callback',
|
||||
'/auth/wechat/callback'
|
||||
'/auth/wechat/callback',
|
||||
'/auth/wechat/payment/callback',
|
||||
]
|
||||
const BACKEND_MODE_PENDING_AUTH_PATHS = ['/register', '/email-verify']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user