samedi 19 août 2017

Laravel - How to accomplish authentication by permission?

I read the documentation about authentication and i'm little bit confuse.

I want to create a trait that log in users by permission, the idea is to create method on any controller that belongs to any part of the application (Admin, Normal user, Customer service), and from that method send the right permission to the trait login method.

The problem that I encounter is: How do I authenticate user by permission? Assume that I have permissions table and that table connected via another table to Users table. (many to many).

Is that mean that I should create a Guard for any part of the application?

Is there any other way to accomplish that?

I do can query for permission and then use Auth::attempt in order to log in user, but it's two queries and I thing it's kind of waste.

thanks



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2uRCFZG
via IFTTT

Aucun commentaire:

Enregistrer un commentaire