original_string: public function socialCallback(Request $request, $serviceName)
      {
          try {
              $this->setDynamicRedirectUrl($serviceName);
              $user = $this->socialite->driver($serviceName)->user();
              $this->authService->login($serviceName, $user);
              return redirect(session('url.intended', '/'));
          } catch (\Exception $e) {
              Log::error('Social login failed: ' . $e->getMessage() . ' - ' . print_r($request->all(), true));
              if (session()->has('url.intended')) { // If redirect url exists show translated error to the user
                  $reditectUrl = session('url.intended');
                  session()->forget('url.intended'); // remove intended url
                  // Set flash message
                  session()->flash(
                      'messages',
                      [
                          [
                              'code' => 'error',
                              'text' => $e->getMessage()
                          ]
                      ]
                  );
                  return redirect($reditectUrl);
              } else {
                  return app()->abort(500, $e->getMessage());
              }
          }
      }
code: public function socialCallback(Request $request, $serviceName)
      {
          try {
              $this->setDynamicRedirectUrl($serviceName);
              $user = $this->socialite->driver($serviceName)->user();
              $this->authService->login($serviceName, $user);
              return redirect(session('url.intended', '/'));
          } catch (\Exception $e) {
              Log::error('Social login failed: ' . $e->getMessage() . ' - ' . print_r($request->all(), true));
              if (session()->has('url.intended')) { // If redirect url exists show translated error to the user
                  $reditectUrl = session('url.intended');
                  session()->forget('url.intended'); // remove intended url
                  // Set flash message
                  session()->flash(
                      'messages',
                      [
                          [
                              'code' => 'error',
                              'text' => $e->getMessage()
                          ]
                      ]
                  );
                  return redirect($reditectUrl);
              } else {
                  return app()->abort(500, $e->getMessage());
              }
          }
      }
code_tokens: public function socialCallback ( Request $ request , $ serviceName ) { try { $ this -> setDynamicRedirectUrl ( $ serviceName ) ; $ user = $ this -> socialite -> driver ( $ serviceName ) -> user ( ) ; $ this -> authService -> login ( $ serviceName , $ user ) ; return redirect ( session ( 'url.intended' , '/' ) ) ; } catch ( \ Exception $ e ) { Log :: error ( 'Social login failed: ' . $ e -> getMessage ( ) . ' - ' . print_r ( $ request -> all ( ) , true ) ) ; if ( session ( ) -> has ( 'url.intended' ) ) { // If redirect url exists show translated error to the user $ reditectUrl = session ( 'url.intended' ) ; session ( ) -> forget ( 'url.intended' ) ; // remove intended url // Set flash message session ( ) -> flash ( 'messages' , [ [ 'code' => 'error' , 'text' => $ e -> getMessage ( ) ] ] ) ; return redirect ( $ reditectUrl ) ; } else { return app ( ) -> abort ( 500 , $ e -> getMessage ( ) ) ; } } }
docstring: Function responsible for handle a callback request from the given social service.
  
  @param Request $request     Request object
  @param string  $serviceName string social service name
  
  @return \Illuminate\Http\RedirectResponse
docstring_tokens: Function responsible for handle a callback request from the given social service .