Support the ongoing development of Laravel.io →
Authentication
Last updated 2 years ago.
0

When you first log in the user, couldn't you also have a field in the database called role, where its either
admin or user? Then once logged in if the role field is admin, maybe set a session to user_role.
Then:

public function handle($request, Closure $next)
    {

        if (Session::get('user_role') == "admin"))
        {
                return redirect()->guest('/');
        }

        return $next($request);
    }
0

I checked something:
Right after login in the AuthController:

$yourvar = $request->user()->role;

Now $yourvar is the role, do whatever works now.
This is L5 right?

0

yes thank you

0

Sign in to participate in this thread!

Eventy

Your banner here too?

tamirh67 tamirh67 Joined 24 Nov 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.