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

StandBehindGoat's avatar

Breeze Multi Authentication

I'm kinda new to Laravel and I made a Login and Registration page using the Breeze scaffolding, and I'm lost on how to separate the default landing page for the user and the admin. I know i can use an if statement to check if the user logging has admin rights or not, should i make a LoginController?

0 likes
3 replies
CorvS's avatar
CorvS
Best Answer
Level 27

@whippersnapper Yes, just check if the user is an admin and show the admin dashboard (or the user dashboard).

For example:

// Wrapped in "auth" middleware
Route::get('dashboard', function () {
    if (Auth::user()->isAdmin())
        return view('admin-dashboard');

    return view('user-dashboard');
});

Or just reference the appropriate controllers, whatever fits your case best.

1 like
StandBehindGoat's avatar

I'm currently using the Breeze Scaffolding maybe it has a premade LoginController?

It has a LoginRequest.php

public function authenticate()
    {
        $this->ensureIsNotRateLimited();

        if (! Auth::attempt($this->only('email', 'password'), $this->filled('remember'))) {
            RateLimiter::hit($this->throttleKey());

            throw ValidationException::withMessages([
                'email' => __('auth.failed'),
            ]);
        }

        RateLimiter::clear($this->throttleKey());
    }

maybe I can throw my validation here? like

if(auth()->attempt(array('email' => $inputVal['email'], 'password' => $inputVal['password']))){
            if (auth()->user()->is_admin == 1) {
                return redirect()->route('admin.route');
            }else{
                return redirect()->route('home');
            }
        }else{
            return redirect()->route('login')
                ->with('error','Email & Password are incorrect.');
        }     

and btw thank you for your response NIMROD :)

CorvS's avatar

@whippersnapper By default the Breeze login redirects the user to /dashboard (or rather the route defined in HOME of the RouteServiceProvider), so you don't have to change any of the login code directly.

1 like

Please or to participate in this conversation.