Skip to content

Commit 15002cb

Browse files
authored
Merge pull request #59680 from piepre/occ-token-login-name
feat: allow setting custom login-name for occ generated app password
2 parents a813519 + 8998905 commit 15002cb

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

  • core/Command/User/AuthTokens

core/Command/User/AuthTokens/Add.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ protected function configure() {
5656
InputOption::VALUE_REQUIRED,
5757
'Name for the app password, defaults to "cli".'
5858
)
59+
->addOption(
60+
'login-name',
61+
null,
62+
InputOption::VALUE_REQUIRED,
63+
'Optional login-name, defaults to UID'
64+
)
5965
;
6066
}
6167

@@ -90,13 +96,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9096
$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>');
9197
}
9298

99+
$loginName = $input->getOption('login-name') ?? $user->getUID();
100+
93101
$tokenName = $input->getOption('name') ?: 'cli';
94102

95103
$token = $this->random->generate(72, ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS);
96104
$generatedToken = $this->tokenProvider->generateToken(
97105
$token,
98106
$user->getUID(),
99-
$user->getUID(),
107+
$loginName,
100108
$password,
101109
$tokenName,
102110
IToken::PERMANENT_TOKEN,

0 commit comments

Comments
 (0)