You are here

class UserAuthenticator in Social Post 3.x

Same name and namespace in other branches
  1. 8.2 src/User/UserAuthenticator.php \Drupal\social_post\User\UserAuthenticator

Manages Drupal authentication tasks for Social Post.

Hierarchy

Expanded class hierarchy of UserAuthenticator

1 file declares its use of UserAuthenticator
OAuth2ControllerBase.php in src/Controller/OAuth2ControllerBase.php
1 string reference to 'UserAuthenticator'
social_post.services.yml in ./social_post.services.yml
social_post.services.yml
1 service uses UserAuthenticator
social_post.user_authenticator in ./social_post.services.yml
Drupal\social_post\User\UserAuthenticator

File

src/User/UserAuthenticator.php, line 10

Namespace

Drupal\social_post\User
View source
class UserAuthenticator extends SocialApiUserAuthenticator {

  /**
   * The Social Post User Manager.
   *
   * @var \Drupal\social_post\User\UserManager
   */
  protected $userManager;

  /**
   * Gets the Drupal user id based on the provider user id.
   *
   * @param string $provider_user_id
   *   User's id on provider.
   *
   * @return int|false
   *   The Drupal user id if it exists.
   *   False otherwise.
   */
  public function getDrupalUserId($provider_user_id) {
    return $this->userManager
      ->getDrupalUserId($provider_user_id);
  }

  /**
   * Add user record in Social Post Entity.
   *
   * @param string $name
   *   The user name in the provider.
   * @param int|string $provider_user_id
   *   Unique Social ID returned by social network.
   * @param string $url
   *   The URL to the profile in the provider.
   * @param string $token
   *   Token to be used for autoposting.
   *
   * @return bool
   *   True if User record was created or False otherwise
   */
  public function addUserRecord($name, $provider_user_id, $url, $token) {
    return $this->userManager
      ->addUserRecord($name, $this
      ->currentUser()
      ->id(), $provider_user_id, $url, $token);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
UserAuthenticator::$currentUser protected property The current Drupal user.
UserAuthenticator::$dataHandler protected property The Social API data handler.
UserAuthenticator::$entityType protected property The entity type.
UserAuthenticator::$entityTypeManager protected property The Drupal Entity Manager.
UserAuthenticator::$loggerFactory protected property The Drupal logger factory.
UserAuthenticator::$messenger protected property The Messenger service.
UserAuthenticator::$pluginId protected property The implementer plugin id.
UserAuthenticator::$sessionKeys protected property Session keys to nullify is user could not be logged in.
UserAuthenticator::$userManager protected property The Social Post User Manager. Overrides UserAuthenticator::$userManager
UserAuthenticator::addUserRecord public function Add user record in Social Post Entity.
UserAuthenticator::currentUser public function Returns the current user.
UserAuthenticator::getDrupalUserId public function Gets the Drupal user id based on the provider user id.
UserAuthenticator::getPluginId public function Gets the implementer plugin id.
UserAuthenticator::nullifySessionKeys public function Nullifies session keys if user could not logged in.
UserAuthenticator::setPluginId public function Sets the implementer plugin id.
UserAuthenticator::setSessionKeysToNullify public function Sets the session keys to nullify if user could not logged in.
UserAuthenticator::__construct public function Constructor.