mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-11-03 20:48:07 +00:00 
			
		
		
		
	- Switch to pnpm based build - Switch circleci from docker to machine to have more memory - Fix frontend and backend tests Fixes https://linear.app/chatwoot/issue/CW-3610/fix-circle-ci-for-vite-build --------- Co-authored-by: Shivam Mishra <scm.mymail@gmail.com> Co-authored-by: Pranav <pranavrajs@gmail.com> Co-authored-by: Pranav <pranav@chatwoot.com>
		
			
				
	
	
		
			47 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
import { createRouter, createWebHistory } from 'vue-router';
 | 
						|
 | 
						|
import { frontendURL } from '../helper/URLHelper';
 | 
						|
import dashboard from './dashboard/dashboard.routes';
 | 
						|
import store from 'dashboard/store';
 | 
						|
import { validateLoggedInRoutes } from '../helper/routeHelpers';
 | 
						|
import AnalyticsHelper from '../helper/AnalyticsHelper';
 | 
						|
import { buildPermissionsFromRouter } from '../helper/permissionsHelper';
 | 
						|
 | 
						|
const routes = [...dashboard.routes];
 | 
						|
 | 
						|
export const router = createRouter({ history: createWebHistory(), routes });
 | 
						|
export const routesWithPermissions = buildPermissionsFromRouter(routes);
 | 
						|
 | 
						|
export const validateAuthenticateRoutePermission = (to, next) => {
 | 
						|
  const { isLoggedIn, getCurrentUser: user } = store.getters;
 | 
						|
 | 
						|
  if (!isLoggedIn) {
 | 
						|
    window.location.assign('/app/login');
 | 
						|
    return '';
 | 
						|
  }
 | 
						|
 | 
						|
  if (!to.name) {
 | 
						|
    return next(frontendURL(`accounts/${user.account_id}/dashboard`));
 | 
						|
  }
 | 
						|
 | 
						|
  const nextRoute = validateLoggedInRoutes(to, store.getters.getCurrentUser);
 | 
						|
  return nextRoute ? next(frontendURL(nextRoute)) : next();
 | 
						|
};
 | 
						|
 | 
						|
export const initalizeRouter = () => {
 | 
						|
  const userAuthentication = store.dispatch('setUser');
 | 
						|
 | 
						|
  router.beforeEach((to, _from, next) => {
 | 
						|
    AnalyticsHelper.page(to.name || '', {
 | 
						|
      path: to.path,
 | 
						|
      name: to.name,
 | 
						|
    });
 | 
						|
 | 
						|
    userAuthentication.then(() => {
 | 
						|
      return validateAuthenticateRoutePermission(to, next, store);
 | 
						|
    });
 | 
						|
  });
 | 
						|
};
 | 
						|
 | 
						|
export default router;
 |