lundi 20 juin 2016

Protecting routes

I am trying to figure something out. I am using the following library It basically connects to LDAP so I can pull all my users from Active Directory. It is however just an extension of the built in Auth class.

What I do is get my users from LDAP. I then get my departments from LDAP. Finally, I link a user to a single department. To get all users for a particular department I can then do something like this

$department = Department::where('departmentName', 'Department A')->first();
$sdUsers = $department->user;

Now I only want to give access to some routes for users in Department A. I could pass these users to the view and do it this way but I think it will be messy. How can I use Middleware to restrict access based on a particular department?

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire