email) ->where('company_id', $company->id) ->first(); if (! $user || ! Hash::check($request->password, $user->password)) { throw ValidationException::withMessages([ 'email' => ['The provided credentials are incorrect.'], ]); } if (! $user->enable_portal) { throw ValidationException::withMessages([ 'email' => ['Customer portal not available for this user.'], ]); } Auth::guard('customer')->login($user); return response()->json([ 'success' => true ]); } }