+
+ // Check request for error information
+ if ($request->has('error') && $request->has('error_description')) {
+ throw new SocialSignInException(trans('errors.social_login_bad_response', [
+ 'socialAccount' => $socialDriver,
+ 'error' => $request->get('error_description'),
+ ]), '/login');
+ }
+
+ $action = session()->pull('social-callback');
+
+ // Attempt login or fall-back to register if allowed.
+ $socialUser = $this->socialAuthService->getSocialUser($socialDriver);
+ if ($action == 'login') {
+ try {
+ return $this->socialAuthService->handleLoginCallback($socialDriver, $socialUser);
+ } catch (SocialSignInAccountNotUsed $exception) {
+ if ($this->socialAuthService->driverAutoRegisterEnabled($socialDriver)) {
+ return $this->socialRegisterCallback($socialDriver, $socialUser);
+ }
+ throw $exception;
+ }
+ }
+
+ if ($action == 'register') {
+ return $this->socialRegisterCallback($socialDriver, $socialUser);
+ }
+