You are here

protected function TfaTrustedBrowser::deleteTrusted in Two-factor Authentication (TFA) 8

Delete users trusted browser.

Parameters

string $id: (optional) Id of the browser to be purged.

Return value

bool TRUE is id found and purged otherwise FALSE.

3 calls to TfaTrustedBrowser::deleteTrusted()
TfaTrustedBrowserSetup::deleteTrustedBrowsers in src/Plugin/TfaSetup/TfaTrustedBrowserSetup.php
Delete all trusted browsers.
TfaTrustedBrowserSetup::deleteTrustedId in src/Plugin/TfaSetup/TfaTrustedBrowserSetup.php
Delete a trusted browser by its ID.
TfaTrustedBrowserSetup::submitSetupForm in src/Plugin/TfaSetup/TfaTrustedBrowserSetup.php
Submit the setup form.

File

src/Plugin/TfaLogin/TfaTrustedBrowser.php, line 205

Class

TfaTrustedBrowser
Trusted browser validation class.

Namespace

Drupal\tfa\Plugin\TfaLogin

Code

protected function deleteTrusted($id = '') {
  $result = $this
    ->getUserData('tfa', 'tfa_trusted_browser', $this->uid, $this->userData);
  if ($id) {
    if (isset($result[$id])) {
      unset($result[$id]);
      $data = [
        'tfa_trusted_browser' => $result,
      ];
      $this
        ->setUserData('tfa', $data, $this->uid, $this->userData);
      return TRUE;
    }
  }
  else {
    $this
      ->deleteUserData('tfa', 'tfa_trusted_browser', $this->uid, $this->userData);
    return TRUE;
  }
  return FALSE;
}