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

Answer by basak for Login only if user is active using Laravel

$
0
0

Laravel 6.6 tested. Overwrite validateLogin in your LoginController.php

use Illuminate\Http\Request;use App\User;use Illuminate\Validation\ValidationException;

......

/** * Validate the user login request. * * @param  \Illuminate\Http\Request  $request * @return void * * @throws \Illuminate\Validation\ValidationException */protected function validateLogin(Request $request){    // Get the user details from database and check if user is exist and active.    $user = User::where('email',$request->email)->first();    if( $user && !$user->activation){        throw ValidationException::withMessages([$this->username() => __('User has been desactivated.')]);    }    // Then, validate input.    return $request->validate([        $this->username() => 'required|string','password' => 'required|string',    ]);}

Viewing all articles
Browse latest Browse all 25

Trending Articles



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