How to add extra condition while login user form in laravel?
How to add extra condition in login form in laravel
First open these folder
Yoursite|vendor\laravel\framework\src\Illuminate\Foundation\Auth
then find public function login(Request $request) this funcation
add these line at the top of funcation
$user = User::where('email',$request->email)->first();
if($user && $user->role!=1){
return redirect()->back()->with('error','You are not an admin.');
}
$user->role or any other condition which you want to check
then go to view where you will show this error
Copy and paste this code
@if($message = Session::get('error'))
<div class="errorlv">
<i class="zmdi zmdi-alert-circle"></i> {{ $message }}
</div>
@endif
Comments
Post a Comment