Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion core/Command/User/AuthTokens/Add.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ protected function configure() {
InputOption::VALUE_REQUIRED,
'Name for the app password, defaults to "cli".'
)
->addOption(
'login-name',
null,
InputOption::VALUE_REQUIRED,
'Optional login-name, defaults to UID'
)
;
}

Expand Down Expand Up @@ -89,13 +95,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$output->writeln('<info>No password provided. The generated app password will therefore have limited capabilities. Any operation that requires the login password will fail.</info>');
}

$loginName = $input->getOption('login-name') ?? $user->getUID();

$tokenName = $input->getOption('name') ?: 'cli';

$token = $this->random->generate(72, ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS);
$generatedToken = $this->tokenProvider->generateToken(
$token,
$user->getUID(),
$user->getUID(),
$loginName,
$password,
$tokenName,
IToken::PERMANENT_TOKEN,
Expand Down