vikas.badola
vikas.badola

Reputation: 137

How to use user roles with auth component in laravel4

I am using laravel 4 auth . I have groups table , which defines user groups. My question here is :

Is there a way to use user groups with larvel auth ? If not then please suggest me what should i do to accomplish this . Thanks.

Upvotes: 1

Views: 2395

Answers (2)

chris342423
chris342423

Reputation: 451

There are several Laravel-specifical packages that you can use to solve this task: - Sentry 2 https://github.com/cartalyst/sentry (Docs: https://cartalyst.com/manual/sentry) - Confide https://github.com/Zizaco/confide - plus others, but Sentry and Confide are the most popular

Upvotes: 2

ajtrichards
ajtrichards

Reputation: 30565

Laravel's Auth functionality is purely to check if the user is valid / logged in. It doesn't provide any role or group management. This would be something you'd need to build yourself.

You can use Laravel's Auth::user() method to access data about the logged in user, which you can then use to check what a group a user is in and if they have required access.

In your application's controllers you can define what group access is required to do certain actions.

There is a Laravel package that may help you with a role based structure: https://github.com/Zizaco/entrust

Upvotes: 0

Related Questions