You are here

public function BakeryService::userExternalLogin in Bakery Single Sign-On System 8.2

Perform standard Drupal login operations for a user object.

The user object must already be authenticated. This function verifies that the user account is not blocked/denied and then performs the login, updates the login timestamp in the database, invokes hook_user('login'), and regenerates the session.

Parameters

\Drupal\user\UserInterface $account: An authenticated user object to be set as the currently logged in user.

Return value

bool TRUE if the login succeeds, FALSE otherwise.

File

src/BakeryService.php, line 79
Services used in bakery SSO functions.

Class

BakeryService
Common functionalities used in both controller and module.

Namespace

Drupal\bakery

Code

public function userExternalLogin(UserInterface $account) {
  if (user_is_blocked($account
    ->getAccountName())) {

    // Invalid login.
    return FALSE;
  }

  // Valid login.
  user_login_finalize($account);
  return TRUE;
}