Fix frontend login flow: merge v3 auth routes, fix vite proxy, SPA redirect
This commit is contained in:
@@ -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');
|
||||
};
|
||||
}
|
||||
|
||||
@@ -85,10 +85,18 @@ export default defineConfig({
|
||||
target: process.env.VITE_API_HOST || 'http://127.0.0.1:3000',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/auth': {
|
||||
target: process.env.VITE_API_HOST || 'http://127.0.0.1:3000',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/platform': {
|
||||
target: process.env.VITE_API_HOST || 'http://127.0.0.1:3000',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/profile': {
|
||||
target: process.env.VITE_API_HOST || 'http://127.0.0.1:3000',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/cable': {
|
||||
target: process.env.VITE_API_HOST || 'http://127.0.0.1:3000',
|
||||
ws: true,
|
||||
|
||||
Reference in New Issue
Block a user