original_string: public function loginFromOAuthResponseAction()
      {
          $userManager = $this->container->get('fos_user.user_manager');
          $userIdentityField = $this->container->get('rch_jwt_user.user_identity_field');
  
          $data = $this->get('rch_jwt_user.credential_fetcher')
              ->create([
                  $userIdentityField      => ['requirements' => $userIdentityField == 'email' ? new Email() : '[^/+]'],
                  'facebook_id'           => ['requirements' => '\d+'],
                  'facebook_access_token' => ['requirements' => '[^/]+'],
              ])
              ->all();
  
          if (true !== $this->isValidFacebookAccount($data['facebook_id'], $data['facebook_access_token'])) {
              throw new InvalidPropertyUserException('The given facebook_id does not correspond to a valid acount');
          }
  
          $user = $userManager->findUserBy(['facebookId' => $data['facebook_id']]);
  
          if ($user) {
              return $this->renderToken($user);
          }
  
          $user = $userManager->findUserBy([$userIdentityField => $data[$userIdentityField]]);
  
          if ($user) {
              $user->setFacebookId($data['facebook_id']);
              $userManager->updateUser($user);
  
              return $this->renderToken($user);
          }
  
          $data['password'] = $this->generateRandomPassword();
  
          return $this->renderToken($this->createUser($data));
      }
code: public function loginFromOAuthResponseAction()
      {
          $userManager = $this->container->get('fos_user.user_manager');
          $userIdentityField = $this->container->get('rch_jwt_user.user_identity_field');
  
          $data = $this->get('rch_jwt_user.credential_fetcher')
              ->create([
                  $userIdentityField      => ['requirements' => $userIdentityField == 'email' ? new Email() : '[^/+]'],
                  'facebook_id'           => ['requirements' => '\d+'],
                  'facebook_access_token' => ['requirements' => '[^/]+'],
              ])
              ->all();
  
          if (true !== $this->isValidFacebookAccount($data['facebook_id'], $data['facebook_access_token'])) {
              throw new InvalidPropertyUserException('The given facebook_id does not correspond to a valid acount');
          }
  
          $user = $userManager->findUserBy(['facebookId' => $data['facebook_id']]);
  
          if ($user) {
              return $this->renderToken($user);
          }
  
          $user = $userManager->findUserBy([$userIdentityField => $data[$userIdentityField]]);
  
          if ($user) {
              $user->setFacebookId($data['facebook_id']);
              $userManager->updateUser($user);
  
              return $this->renderToken($user);
          }
  
          $data['password'] = $this->generateRandomPassword();
  
          return $this->renderToken($this->createUser($data));
      }
code_tokens: public function loginFromOAuthResponseAction ( ) { $ userManager = $ this -> container -> get ( 'fos_user.user_manager' ) ; $ userIdentityField = $ this -> container -> get ( 'rch_jwt_user.user_identity_field' ) ; $ data = $ this -> get ( 'rch_jwt_user.credential_fetcher' ) -> create ( [ $ userIdentityField => [ 'requirements' => $ userIdentityField == 'email' ? new Email ( ) : '[^/+]' ] , 'facebook_id' => [ 'requirements' => '\d+' ] , 'facebook_access_token' => [ 'requirements' => '[^/]+' ] , ] ) -> all ( ) ; if ( true !== $ this -> isValidFacebookAccount ( $ data [ 'facebook_id' ] , $ data [ 'facebook_access_token' ] ) ) { throw new InvalidPropertyUserException ( 'The given facebook_id does not correspond to a valid acount' ) ; } $ user = $ userManager -> findUserBy ( [ 'facebookId' => $ data [ 'facebook_id' ] ] ) ; if ( $ user ) { return $ this -> renderToken ( $ user ) ; } $ user = $ userManager -> findUserBy ( [ $ userIdentityField => $ data [ $ userIdentityField ] ] ) ; if ( $ user ) { $ user -> setFacebookId ( $ data [ 'facebook_id' ] ) ; $ userManager -> updateUser ( $ user ) ; return $ this -> renderToken ( $ user ) ; } $ data [ 'password' ] = $ this -> generateRandomPassword ( ) ; return $ this -> renderToken ( $ this -> createUser ( $ data ) ) ; }
docstring: Registers and authenticates User from a facebook OAuth Response.
  
  @return object The authentication token
docstring_tokens: Registers and authenticates User from a facebook OAuth Response .