Skip to content

Commit bb518b6

Browse files
pieprecome-nc
andcommitted
feat: allow setting custom login-name for occ generated app password
Signed-off-by: piepre <piepre@gmx.de> Update core/Command/User/AuthTokens/Add.php Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com> Signed-off-by: piepre <piepre@gmx.de>
1 parent f501b44 commit bb518b6

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
@@ -55,6 +55,12 @@ protected function configure() {
5555
InputOption::VALUE_REQUIRED,
5656
'Name for the app password, defaults to "cli".'
5757
)
58+
->addOption(
59+
'login-name',
60+
null,
61+
InputOption::VALUE_REQUIRED,
62+
'Optional login-name, defaults to UID'
63+
)
5864
;
5965
}
6066

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

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

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

0 commit comments

Comments
 (0)