original_string: public function login($serviceName, AbstractUser $response)
      {
          $userId = $this->repo->getUserIdBySocialId($response->id, $serviceName);
          if (auth()->check()) { // user already logged and service has not been connected
              $user = auth()->user();
              if ($userId) { // This service has already been connected
                  session()->put('url.intended', route('connectedServices'));
                  throw new SocialException(
                      trans(
                          'gzero-social::common.service_already_connected_message',
                          ['service_name' => title_case($serviceName)]
                      )
                  );
              } else { // create connection for new service
                  $this->repo->addUserSocialAccount($user, $serviceName, $response);
              }
          } else {
              if ($userId) { // login user with this service
                  $this->auth->loginUsingId($userId);
              } else { // create new user
                  $user = $this->repo->createNewUser($serviceName, $response);
                  $this->auth->login($user);
                  session()->put('showWelcomePage', true);
                  session()->put('url.intended', route('account.welcome', ['method' => title_case($serviceName)]));
              }
          }
      }
code: public function login($serviceName, AbstractUser $response)
      {
          $userId = $this->repo->getUserIdBySocialId($response->id, $serviceName);
          if (auth()->check()) { // user already logged and service has not been connected
              $user = auth()->user();
              if ($userId) { // This service has already been connected
                  session()->put('url.intended', route('connectedServices'));
                  throw new SocialException(
                      trans(
                          'gzero-social::common.service_already_connected_message',
                          ['service_name' => title_case($serviceName)]
                      )
                  );
              } else { // create connection for new service
                  $this->repo->addUserSocialAccount($user, $serviceName, $response);
              }
          } else {
              if ($userId) { // login user with this service
                  $this->auth->loginUsingId($userId);
              } else { // create new user
                  $user = $this->repo->createNewUser($serviceName, $response);
                  $this->auth->login($user);
                  session()->put('showWelcomePage', true);
                  session()->put('url.intended', route('account.welcome', ['method' => title_case($serviceName)]));
              }
          }
      }
code_tokens: public function login ( $ serviceName , AbstractUser $ response ) { $ userId = $ this -> repo -> getUserIdBySocialId ( $ response -> id , $ serviceName ) ; if ( auth ( ) -> check ( ) ) { // user already logged and service has not been connected $ user = auth ( ) -> user ( ) ; if ( $ userId ) { // This service has already been connected session ( ) -> put ( 'url.intended' , route ( 'connectedServices' ) ) ; throw new SocialException ( trans ( 'gzero-social::common.service_already_connected_message' , [ 'service_name' => title_case ( $ serviceName ) ] ) ) ; } else { // create connection for new service $ this -> repo -> addUserSocialAccount ( $ user , $ serviceName , $ response ) ; } } else { if ( $ userId ) { // login user with this service $ this -> auth -> loginUsingId ( $ userId ) ; } else { // create new user $ user = $ this -> repo -> createNewUser ( $ serviceName , $ response ) ; $ this -> auth -> login ( $ user ) ; session ( ) -> put ( 'showWelcomePage' , true ) ; session ( ) -> put ( 'url.intended' , route ( 'account.welcome' , [ 'method' => title_case ( $ serviceName ) ] ) ) ; } } }
docstring: Login using social service.
  
  @param $serviceName string social service name
  @param $response    AbstractUser response data
  
  @throws SocialException
docstring_tokens: Login using social service .