+ * Start the social registration process
+ * @param string $socialDriver
+ * @return \Symfony\Component\HttpFoundation\RedirectResponse
+ * @throws SocialDriverNotConfigured
+ */
+ public function startRegister($socialDriver)
+ {
+ $driver = $this->validateDriver($socialDriver);
+ return $this->socialite->driver($driver)->redirect();
+ }
+
+ /**
+ * Handle the social registration process on callback.
+ * @param $socialDriver
+ * @return \Laravel\Socialite\Contracts\User
+ * @throws SocialDriverNotConfigured
+ * @throws UserRegistrationException
+ */
+ public function handleRegistrationCallback($socialDriver)
+ {
+ $driver = $this->validateDriver($socialDriver);
+
+ // Get user details from social driver
+ $socialUser = $this->socialite->driver($driver)->user();
+
+ // Check social account has not already been used
+ if ($this->socialAccount->where('driver_id', '=', $socialUser->getId())->exists()) {
+ throw new UserRegistrationException(trans('errors.social_account_in_use', ['socialAccount'=>$socialDriver]), '/login');
+ }
+
+ if ($this->userRepo->getByEmail($socialUser->getEmail())) {
+ $email = $socialUser->getEmail();
+ throw new UserRegistrationException(trans('errors.social_account_in_use', ['socialAccount'=>$socialDriver, 'email' => $email]), '/login');
+ }
+
+ return $socialUser;
+ }
+
+ /**
+ * Handle the login process on a oAuth callback.