Answer the question
In order to leave comments, you need to log in
How to manage roles and rights in Laravel 5 and VUE.JS?
Good day!
The plans are to make a news site with the ability for users to add, edit, etc. (something like CMS). Laravel 5.6 as backend and Vue.JS as frontend.
Accordingly, I would like to divide users into roles - someone can, but someone cannot do anything. If Laravel is more or less clear, then everything is bad with vuejs. I would like to use common data, but how best to implement without a clue.
Actually the question is: Is there any package / module for combining all this into one system? If there is a lesson about this, I will be very glad if you share this lesson!)
PS: Now I liked it and use this library - Bouncer (For Laravel 5).
Thanks in advance.
Answer the question
In order to leave comments, you need to log in
It is easy to implement:
on the back, use the bouncer + $this->authorize/Gate::allows and check the necessary rights, regardless of the front.
you send to the front from the back, take an array of permissions (ability in the bouncer), in the same place where you transfer the user (it doesn’t matter, with a separate request or immediately when the page loads). Write the necessary getters in vuex, as an example from my project:
export const can = (state) => (perm) => this.loggedIn(state) && state.authUser.abilities.includes(perm);
export const canAny = (state) => (perms) => perms.some(x => this.can(state)(x));
I liked this option (but I haven't tried it yet): Implementing Laravel's Authorization on the Front-End
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question