diff options
author | Lucas Azevedo <lhs_azevedo@hotmail.com> | 2023-08-25 11:13:34 -0300 |
---|---|---|
committer | Lucas Azevedo <lhs_azevedo@hotmail.com> | 2023-08-25 11:20:34 -0300 |
commit | 9c66bf6dc3ca29ac52f6fd83ff0d05edafb917b3 (patch) | |
tree | 2696a5c9b7af9f6b30ab250ef7507920a9ae01b6 /core/Command | |
parent | 2a36acfc2b774340099f9c8445a4f48337026225 (diff) | |
download | nextcloud-server-9c66bf6dc3ca29ac52f6fd83ff0d05edafb917b3.tar.gz nextcloud-server-9c66bf6dc3ca29ac52f6fd83ff0d05edafb917b3.zip |
Use table output for list command
Signed-off-by: Lucas Azevedo <lhs_azevedo@hotmail.com>
Diffstat (limited to 'core/Command')
-rw-r--r-- | core/Command/User/AuthTokens/ListCommand.php | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/core/Command/User/AuthTokens/ListCommand.php b/core/Command/User/AuthTokens/ListCommand.php index 6739e8b4648..97e94f29f92 100644 --- a/core/Command/User/AuthTokens/ListCommand.php +++ b/core/Command/User/AuthTokens/ListCommand.php @@ -61,18 +61,24 @@ class ListCommand extends Base { $tokens = $this->tokenProvider->getTokenByUser($user->getUID()); - $data = array_map(function (IToken $token): mixed { - $filtered = [ + $tokens = array_map(function (IToken $token) use ($input): mixed { + $sensitive = [ 'password', 'password_hash', 'token', 'public_key', 'private_key', ]; - return array_diff_key($token->jsonSerialize(), array_flip($filtered)); + $data = array_diff_key($token->jsonSerialize(), array_flip($sensitive)); + + if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) { + $data['scope'] = implode(', ', array_keys(array_filter($data['scope']))); + } + + return $data; }, $tokens); - $this->writeArrayInOutputFormat($input, $output, $data); + $this->writeTableInOutputFormat($input, $output, $tokens); return 0; } |