Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
Vue 3 + Quasar create check role global function

I'm trying to create a global function to check authenticated user roles to display components based on his/her roles.

This is my boot file:

import { boot } from 'quasar/wrappers';
import { Store as VuexStore } from 'vuex';
import store, { StateInterface } from 'src/store';

export function canAccess(roles: string[]) {
  const s = store({}) as VuexStore<StateInterface>;
  const userRoles = s.state.auth.profile?.roles;
  const listRoles = userRoles?.map((role) => role.title);
  console.log(listRoles);
  return true;
}

export default boot(({ app }) => {
  app.config.globalProperties.$canAccess = canAccess;
});

I know this code wouldn't check roles, but it logs undefined. I couldn't find a way to get Vue 3 store state (Vuex 4) in js/ts module to check user roles.

How can i do that in Vue3 + Vuex4 + Quasar?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!