You are here

public static function LogintobogganUtility::processValidation in LoginToboggan 8

Add trusted role to new user when validating from an email link.

Parameters

object $account: User account.

2 calls to LogintobogganUtility::processValidation()
LogintobogganController::logintobogganValidateEmail in src/Controller/LogintobogganController.php
This will return the output of the page.
logintoboggan_form_user_pass_reset_alter in ./logintoboggan.module
Implements hook_form_user_pass_reset_alter().

File

src/Utility/LogintobogganUtility.php, line 72

Class

LogintobogganUtility
Class for utility methods.

Namespace

Drupal\logintoboggan\Utility

Code

public static function processValidation($account) {
  $trusted_role = self::trustedRole();

  // Core mail verification not required and trusted <>
  // authenticated so add the role.
  $trusted_used = !\Drupal::config('user.settings')
    ->get('verify_mail') && $trusted_role != AccountInterface::AUTHENTICATED_ROLE;
  if (!$account
    ->isBlocked()) {
    if ($trusted_used) {
      $account
        ->addRole($trusted_role);
      $account
        ->save();
    }
  }
}