Merge pull request #3904 from devansh-webkul/social_login_cart_merging

Social login cart merging
This commit is contained in:
Jitendra Singh 2020-09-07 19:35:37 +05:30 committed by GitHub
commit 93309f6d64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -3,9 +3,10 @@
namespace Webkul\SocialLogin\Http\Controllers;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Event;
use Laravel\Socialite\Facades\Socialite;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Laravel\Socialite\Facades\Socialite;
use Webkul\SocialLogin\Repositories\CustomerSocialAccountRepository;
class LoginController extends Controller
@ -51,11 +52,11 @@ class LoginController extends Controller
return Socialite::driver($provider)->redirect();
} catch (\Exception $e) {
session()->flash('error', $e->getMessage());
return redirect()->route('customer.session.index');
}
}
/**
* Handles callback
*
@ -69,11 +70,14 @@ class LoginController extends Controller
} catch (\Exception $e) {
return redirect()->route('customer.session.index');
}
$customer = $this->customerSocialAccountRepository->findOrCreateCustomer($user, $provider);
auth()->guard('customer')->login($customer, true);
// Event passed to prepare cart after login
Event::dispatch('customer.after.login', $customer->email);
return redirect()->intended(route($this->_config['redirect']));
}
}