Multiple role-based authentication in Laravel

Solomon Eseme
Backend Developers
Published in
5 min readJan 26, 2019

--

Hey guys, in this article, am going to show you how to implement multiple role-based authentication in Laravel even if you have many different users and multiple dashboards respectively.

multiple role-based authentication in Laravel

Before we delve into achieving that, let me breakdown my scenarios or problems i was facing in a project I was working for a company, that made me to spent almost two weeks trying to figure it out.

In this project, I was presented with six (6) different users and their respective dashboards too, the users were as follows viz:

  1. Super Admin
  2. Admin
  3. Players
  4. Teams
  5. Academics
  6. Scouts

So, the problem was to redirect the users to their respective dashboards on successful logins and restrict access to any other dashboards even if they typed in the URL to or try to access the other dashboard, it should redirect them back to their default dashboard.

As I read through many blog posts, video tutorials and questionings which was great, I discovered that whenever I successfully implement a solution, I will always discover a fault during security test/checks such as “too many redirect errors” or enabling a logged in player to access a scout dashboard etc.

--

--

Solomon Eseme
Backend Developers

A Software Engineer who’s geared towards building high performing and innovative products. I help you become a great Backend Engineer @ masteringbackend.com