You are here

static function MoAuthUtilities::updateMfaSettingsForUser in Google Authenticator / 2 Factor Authentication - 2FA 8.2

2 calls to MoAuthUtilities::updateMfaSettingsForUser()
miniorange_2fa_inline_registration::handle_skip_mfa in src/Form/miniorange_2fa_inline_registration.php
UserMfaSetup::submitForm in src/Form/UserMfaSetup.php
Form submission handler.

File

src/MoAuthUtilities.php, line 707
This file is part of miniOrange 2FA module.

Class

MoAuthUtilities

Namespace

Drupal\miniorange_2fa

Code

static function updateMfaSettingsForUser($uid, $enableMfa = 1) {

  // Enter the user details in the userAuthenticationType Table
  $database = \Drupal::database();
  $result = self::get_users_custom_attribute($uid);
  if (count($result) > 0) {
    $database
      ->update('UserAuthenticationType')
      ->fields([
      'enabled' => $enableMfa,
    ])
      ->condition('uid', $uid, '=')
      ->execute();
  }
  else {
    $fields = array(
      'uid' => $uid,
      'enabled' => $enableMfa,
    );
    try {
      $database
        ->insert('UserAuthenticationType')
        ->fields($fields)
        ->execute();
    } catch (Exception $e) {
    }
  }
}