user_is_blocked example

else {
      $this->getRequest()->query->set('destination', $this->getRequest()->request->get('destination'));
    }

    user_login_finalize($account);
  }

  /** * Sets an error if supplied username has been blocked. */
  public function validateName(array &$form, FormStateInterface $form_state) {
    if (!$form_state->isValueEmpty('name') && user_is_blocked($form_state->getValue('name'))) {
      // Blocked in user administration.       $form_state->setErrorByName('name', $this->t('The username %name has not been activated or is blocked.', ['%name' => $form_state->getValue('name')]));
    }
  }

  /** * Checks supplied username/password against local users table. * * If successful, $form_state->get('uid') is set to the matching user ID. */
  public function validateAuthentication(array &$form, FormStateInterface $form_state) {
    
/** * Verifies if the user is blocked. * * @param string $name * The username. * * @return bool * TRUE if the user is blocked, otherwise FALSE. */
  protected function userIsBlocked($name) {
    return user_is_blocked($name);
  }

  /** * Finalizes the user login. * * @param \Drupal\user\UserInterface $user * The user. */
  protected function userLoginFinalize(UserInterface $user) {
    user_login_finalize($user);
  }

  
Home | Imprint | This part of the site doesn't use cookies.