You are here

protected function WardenManager::generateNewLocalToken in Warden 8

Same name and namespace in other branches
  1. 8.2 src/Service/WardenManager.php \Drupal\warden\Service\WardenManager::generateNewLocalToken()
  2. 3.x src/Service/WardenManager.php \Drupal\warden\Service\WardenManager::generateNewLocalToken()

Generate and save and new token.

Return value

string

1 call to WardenManager::generateNewLocalToken()
WardenManager::getLocalToken in src/Service/WardenManager.php
Get the local token and generate it if it is not set.

File

src/Service/WardenManager.php, line 233

Class

WardenManager
Default controller for the warden module.

Namespace

Drupal\warden\Service

Code

protected function generateNewLocalToken() {
  $local_token = hash('sha256', mt_rand());
  \Drupal::configFactory()
    ->getEditable('warden.settings')
    ->set('warden_token', $local_token)
    ->save();
  return $local_token;
}