You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{boot}from'quasar/wrappers';import{Router,RouteRecordRaw}from'vue-router';import{isModuleActive}from'../flox';import{MODULES}from'../flox/enum/MODULES';importUserEntityfrom'../flox/modules/auth/entities/user.entity';import{fetchMyUser}from'../flox/modules/auth/services/user.service';import{useAuthStore}from'../flox/modules/auth/stores/auth.store';importROUTES,{CONSTRAINED_ROUTES,PUBLIC_ROUTES}from'../router/routes';// eslint-disable-next-line import/no-mutable-exportsletrouterInstance: Router;/** * Returns the component of the dashboard for the currently logged-in user * * @param user - the user, if any * @param $authStore - authentication store * @returns the layout component */functiongetUserRoleRoute(user: UserEntity|null,$authStore: ReturnType<typeofuseAuthStore>): RouteRecordRaw{// Non-logged in: Redirect to log inif(!user){$authStore.setCognitoUser(undefined);$authStore.setUserSession(undefined);returnROUTES.LOGIN;}returnROUTES.HOME;// TODO application specific: add paths per role// switch (user.role) {// case ROLE.ADMIN:// return ROUTES.CUSTOMERS;// case ROLE.USER:// return ROUTES.CUSTOMERS.path + '/' + user.username;// default:// return ROUTES.LOGIN;// }}exportdefaultboot(({ router })=>{const$authStore=useAuthStore();routerInstance=router;// eslint-disable-next-line sonarjs/cognitive-complexity,consistent-returnrouter.beforeEach(async(to)=>{// Verify valid authenticationconst{ loggedIn }=$authStore;// TODO: Add as part of sharing module// Case 1: trying to access non-public route while not logged in
c34afcdbe6cf8bf4dc8cd9656b2379056bd551f0
The text was updated successfully, but these errors were encountered:
application specific: add paths per role
switch (user.role) {
case ROLE.ADMIN:
return ROUTES.CUSTOMERS;
case ROLE.USER:
return ROUTES.CUSTOMERS.path + '/' + user.username;
default:
return ROUTES.LOGIN;
}
eslint-disable-next-line sonarjs/cognitive-complexity,consistent-return
flox/frontend/src/boot/router.ts
Line 33 in 4d186fe
c34afcdbe6cf8bf4dc8cd9656b2379056bd551f0
The text was updated successfully, but these errors were encountered: