Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Jayaat's avatar
Level 1

Multi user authentication using single using single user table in laravel 11 with api passport

sir how can i able to redirect after successful login on the basis of roles provided inside user table like im using ajax to send request after getting success i want to redirect them their respective page(for starters their dashboards and also not other infiltrate inside each dashboards ) how can i proceed futher? as other example shows to add middleware inside kernel.php but by default i dont have any kind of file and i dont know where to add middleware as well

0 likes
6 replies
vincent15000's avatar

Effectively a middleware seems to be a good solution.

What do you have already tried ?

Jayaat's avatar
Level 1

@vincent15000 i did try when i redirecting them after succes i sends me back 404 error and i didn't get any clear way from any site that if i apply that would the person with different role can access other role person route

1 like
jlrdw's avatar

In passport look at https://laravel.com/docs/11.x/passport#defining-scopes

how can i able to redirect after successful login on the basis of roles provided inside user table like im using ajax to send request after getting success i want to redirect them their respective page

Sound like it needs to be a regular web app and not an API.

1 like
Jayaat's avatar
Level 1

@jlrdw passport does provide only it's security part not multiple user authentication

1 like
vincent15000's avatar

@Jayaat I don't know why you call this **multiuser authentication``` because the problem you are speaking about seems to be only a redirection to a cutom page according to the user's role.

1 like
Jayaat's avatar
Level 1

@vincent15000 basically i created protected routes on role basis such that then can't intervene btw other's routes so that how i say it is multi user authentication

Please or to participate in this conversation.