feat: rebuild auth identity foundation flow

This commit is contained in:
IanShaw027
2026-04-20 17:39:57 +08:00
parent fbd0a2e3c4
commit e9de839d87
123 changed files with 33599 additions and 772 deletions

View File

@@ -0,0 +1,55 @@
import { describe, expect, it, vi } from 'vitest'
const authStore = vi.hoisted(() => ({
checkAuth: vi.fn(),
isAuthenticated: false,
isAdmin: false,
isSimpleMode: false,
}))
const appStore = vi.hoisted(() => ({
siteName: 'Sub2API',
backendModeEnabled: false,
cachedPublicSettings: null as null | Record<string, unknown>,
}))
vi.mock('@/stores/auth', () => ({
useAuthStore: () => authStore,
}))
vi.mock('@/stores/app', () => ({
useAppStore: () => appStore,
}))
vi.mock('@/stores/adminSettings', () => ({
useAdminSettingsStore: () => ({
customMenuItems: [],
}),
}))
vi.mock('@/composables/useNavigationLoading', () => ({
useNavigationLoadingState: () => ({
startNavigation: vi.fn(),
endNavigation: vi.fn(),
isLoading: { value: false },
}),
}))
vi.mock('@/composables/useRoutePrefetch', () => ({
useRoutePrefetch: () => ({
triggerPrefetch: vi.fn(),
cancelPendingPrefetch: vi.fn(),
resetPrefetchState: vi.fn(),
}),
}))
describe('router WeChat OAuth route', () => {
it('registers the WeChat callback route as a public route', async () => {
const { default: router } = await import('@/router')
const route = router.getRoutes().find((record) => record.name === 'WeChatOAuthCallback')
expect(route?.path).toBe('/auth/wechat/callback')
expect(route?.meta.requiresAuth).toBe(false)
expect(route?.meta.title).toBe('WeChat OAuth Callback')
})
})

View File

@@ -83,6 +83,15 @@ const routes: RouteRecordRaw[] = [
title: 'LinuxDo OAuth Callback'
}
},
{
path: '/auth/wechat/callback',
name: 'WeChatOAuthCallback',
component: () => import('@/views/auth/WechatCallbackView.vue'),
meta: {
requiresAuth: false,
title: 'WeChat OAuth Callback'
}
},
{
path: '/auth/oidc/callback',
name: 'OIDCOAuthCallback',