Quantcast
Channel: Login only if user is active using Laravel - Stack Overflow
Viewing all articles
Browse latest Browse all 25

Answer by Duy Nguyen for Login only if user is active using Laravel

$
0
0

In case, you want to keep everything as simple, you can use Laravel built-in feature. It is email verification. I do not guarantee this way would resolve your problem. It is reference in case you didn't know about it before.

Follow the doc at https://laravel.com/docs/7.x/verification, all you have to do are a few steps.

  1. Implementation of the User model with MustVerifyEmail
<?phpnamespace App;use Illuminate\Contracts\Auth\MustVerifyEmail;use Illuminate\Foundation\Auth\User as Authenticatable;use Illuminate\Notifications\Notifiable;class User extends Authenticatable implements MustVerifyEmail{    use Notifiable;    // ...}
  1. Active the middleware verify for the routes in web.php or in controller

  2. You can activate the verification link and verify email

Auth::routes(['verify' => true]);
  1. Make sure the user migration has included email_verified_at column.

I often use this built-in feature if I need verification users before allowing it to access the application.


Viewing all articles
Browse latest Browse all 25

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>