Comments (3)
Hello @N0SYS73M1SS4F3, you could try with:
async created() {
const { data: permissions } = await this.$axios.get("/api/auth/permissions");
const { data: roles } = await this.$axios.get("/api/auth/roles");
this.$laravel.setPermissions(permissions);
this.$laravel.setRoles(roles);
console.log(permissions)
}
from vue-gates.
Hello @williamcruzme yes, i tried ur code, it work, Roles mounted, Permissions mounted,
but i try bind permission to User to See Sidebar base On Roles by implement like this
in My template
<div v-for="(item, i) in menus" :key="i" router exact>
<div v-if="$laravel.hasPermission(item.permission)">
<template v-if="!item.children">
<v-list-item :key="i" :to="item.to">
<v-list-item-content>
<v-list-item-title>
<v-icon left>{{ item.icon }}</v-icon>
{{ item.name }}
</v-list-item-title>
</v-list-item-content>
</v-list-item>
</template>
in my <script>
menus: [
{
name: "Dashboard",
icon: "mdi-view-dashboard",
to: "/",
permission: "view users"
},
When logged In, Every roles can see sidebar the same as Admin Role, Except Reload Pagee..
Is there a way to archieve it???
Sorry for ma bad English....
Edit: if i do my code like below, it work perfectly
created() {
if (this.user.role[0] === "administrator") {
this.$laravel.setPermissions("view users");
}
if (this.user.role[0] === "saleman") {
this.$laravel.setPermissions([
"view sales",
"add sales",
"edit sales",
"delete sales",
"import sales",
"summary report",
"product report",
"daily sale report",
"monthly sale report",
"daily purchase report",
"sale report",
"purchase report",
"warehouse report",
"product qty alert",
"customer report",
"supplier report",
"due report",
"pos"
]);
}
}
from vue-gates.
Hi @N0SYS73M1SS4F3, thank you for your time.
Solution
Set the permissions/roles when you log in (before redirect), and enable persistent
feature:
Vue.use(LaravelPermissions, { persistent: true });
Recommend solution
Work with Nuxt.js, you set the permissions/roles on the server side.
from vue-gates.
Related Issues (20)
- TypeScript declaration is wrong HOT 2
- Bug to check similar permissions HOT 1
- Vue3 Working Example
- Just asking for clarification and suggestion
- permissions gets updated after page refresh. HOT 1
- . HOT 1
- Unrecognized Vue directive (Nuxt ^2.13.3)
- superRole implmentation questions HOT 1
- Cannot read properties of null (reading 'includes') Error - After login in NuxtJs HOT 3
- You must specify a value in the directive. - is it possible to be able to pass empty v-permission ? HOT 1
- Changing Permissions removes Parent and Children from DOM in wrong order (using bootstrap) HOT 1
- Prevent a nested component from being loaded
- role or permission not working in vuetify
- TypeError: Cannot read properties of null (reading 'includes') HOT 1
- Unable to use $gates variable in Vue 3 Composition API? HOT 8
- Directives as functions in Vue 3 HOT 4
- Nuxt: getting empty permission on first reload HOT 1
- Unrecognized Vue directive
- this.$gates is not defined in Vue3 with Pinia installed
- TypeError: Cannot read properties of undefined (reading 'setPermissions') in Nuxt.js
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-gates.