]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use table output for list command
authorLucas Azevedo <lhs_azevedo@hotmail.com>
Fri, 25 Aug 2023 14:13:34 +0000 (11:13 -0300)
committerLucas Azevedo <lhs_azevedo@hotmail.com>
Fri, 25 Aug 2023 14:20:34 +0000 (11:20 -0300)
Signed-off-by: Lucas Azevedo <lhs_azevedo@hotmail.com>
core/Command/User/AuthTokens/ListCommand.php

index 6739e8b4648237a2977e9ac608f779b545b4bb95..97e94f29f927f2c08c0b1ef7ace949e63c8e54dd 100644 (file)
@@ -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;
        }