Login only if user is active using Laravel

前端 未结 19 1850
孤城傲影
孤城傲影 2020-11-30 23:26

I\'m currently working on my Laravel app and to prevent spam I decided that only active users are able to login. I\'m currently using Laravel\'s login system just like in La

19条回答
  •  自闭症患者
    2020-11-30 23:54

    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
    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.

提交回复
热议问题