Support the ongoing development of Laravel.io →
Authentication Authorization
Last updated by @ajax30 1 year ago.
0

Here is a working, although not perfect, solution:

In app\Http\Controllers\Auth\LoginController.php, I have overwritten the authenticated method, instead of the credentials method:

protected function authenticated()
{
  if (Auth::user()->active !== 1) {
    Auth::logout();
    return redirect('/login')->withError('Your account is not active!');
  }
}

In the login view, above the form:

<div class="alert alert-danger alert-dismissible">
    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
    <p class="my-0 text-center">{{ session('error') }}</p>
</div>

enter image description here

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Razvan ajax30 Joined 2 Oct 2021

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.