Laravel Breeze: Disable Auto-Login After Registration

Laravel Breeze starter kit registers users and log them in automatically, redirecting to the dashboard. But what if you want the person to log in manually, putting their email and password again after registration?

You need to change two lines in the registration controller:

  1. Delete Auth::login();
  2. Change the redirect from home route to login

app/Http/Controllers/Auth/RegisteredUserController.php:

class RegisteredUserController extends Controller
{
public function store(Request $request): RedirectResponse
{
// ...
 
Auth::login($user);
 
return redirect(RouteServiceProvider::HOME);
return redirect(route('login'));
}
}

In fact, you may even skip the change for the redirect, then this sequence will happen:

  1. Laravel will try to redirect to the HOME which is /dashboard by default
  2. Auth middleware will detect that the user is not logged in and will automatically redirect them back to the login form

But that two-step page loading is not ideal, in my opinion. Also, you may want to show a message on the login page?


Bonus: Show Notification Message

You may also redirect to the login page passing the message to show above the form.

To do that, add the method ->with('status', '[your_message]');

return redirect(route('login'))
->with('status', 'Registration successful. Please log in.');

You don't need to change anything in the Blade. This message will appear automatically, because there's a Blade component for this in the Login file.

resources/views/auth/login.blade.php:

<x-guest-layout>
<!-- Session Status -->
<x-auth-session-status class="mb-4" :status="session('status')" />
 
<form method="POST" action="{{ route('login') }}">
...

If you want to look inside, the component's HTML code is this:

resources/views/components/auth-session-status.blade.php:

@props(['status'])
 
@if ($status)
<div {{ $attributes->merge(['class' => 'font-medium text-sm text-green-600']) }}>
{{ $status }}
</div>
@endif

So, whatever status text you pass as a parameter, it will display above the login form.

avatar

Helpful for beginers :)

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 59 courses (1057 lessons, total 42 h 44 min)
  • 78 long-form tutorials (one new every week)
  • access to project repositories
  • access to private Discord

Recent Premium Tutorials