Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AuthHelper.php

function AuthHelper::storeAuth

Parameters

'prompt'|bool $storeAuth:

File

vendor/composer/composer/src/Composer/Util/AuthHelper.php, line 43

Class

AuthHelper
@author Jordi Boggiano <j.boggiano@seld.be>

Namespace

Composer\Util

Code

public function storeAuth(string $origin, $storeAuth) : void {
    $store = false;
    $configSource = $this->config
        ->getAuthConfigSource();
    if ($storeAuth === true) {
        $store = $configSource;
    }
    elseif ($storeAuth === 'prompt') {
        $answer = $this->io
            ->askAndValidate('Do you want to store credentials for ' . $origin . ' in ' . $configSource->getName() . ' ? [Yn] ', static function ($value) : string {
            $input = strtolower(substr(trim($value), 0, 1));
            if (in_array($input, [
                'y',
                'n',
            ])) {
                return $input;
            }
            throw new \RuntimeException('Please answer (y)es or (n)o');
        }, null, 'y');
        if ($answer === 'y') {
            $store = $configSource;
        }
    }
    if ($store) {
        $store->addConfigSetting('http-basic.' . $origin, $this->io
            ->getAuthentication($origin));
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal