Fix frontend login flow: merge v3 auth routes, fix vite proxy, SPA redirect

This commit is contained in:
2026-07-07 18:57:11 +08:00
parent 82b460fe6f
commit 8aeee9ebc7
4 changed files with 31 additions and 4 deletions
@@ -13,9 +13,11 @@ import AppContainer from './Dashboard.vue';
import Suspended from './suspended/Index.vue';
import NoAccounts from './noAccounts/Index.vue';
import OnboardingAccountDetails from './onboarding/Index.vue';
import v3AuthRoutes from '../../../v3/views/routes';
export default {
routes: [
...v3AuthRoutes,
{
path: frontendURL('accounts/:accountId'),
component: AppContainer,
@@ -12,12 +12,25 @@ const routes = [...dashboard.routes];
export const router = createRouter({ history: createWebHistory(), routes });
const PUBLIC_ROUTE_NAMES = [
'login',
'sso_login',
'auth_signup',
'auth_confirmation',
'auth_verify_email',
'auth_password_edit',
'auth_reset_password',
];
export const validateAuthenticateRoutePermission = async (to, next) => {
const { isLoggedIn, getCurrentUser: user } = store.getters;
if (PUBLIC_ROUTE_NAMES.includes(to.name)) {
return next();
}
if (!isLoggedIn) {
window.location.assign('/app/login');
return '';
return next(frontendURL('login'));
}
const { accounts = [], account_id: accountId } = user;
@@ -108,6 +108,10 @@ initializeChatwootEvents();
initializeAnalyticsEvents();
initalizeRouter();
window.onload = () => {
if (document.readyState === 'complete') {
app.mount('#app');
};
} else {
window.onload = () => {
app.mount('#app');
};
}