diff options
author | Lucas Azevedo <lhs_azevedo@hotmail.com> | 2023-08-27 23:02:52 -0300 |
---|---|---|
committer | Lucas Azevedo <lhs_azevedo@hotmail.com> | 2023-08-27 23:14:27 -0300 |
commit | cc912c3b51be06a7034c397a2b77d7968a28a7bd (patch) | |
tree | 92fd8b4d2c9107da8f0c6a0d3b3e11a8f332d55f /core/Command | |
parent | 9c66bf6dc3ca29ac52f6fd83ff0d05edafb917b3 (diff) | |
download | nextcloud-server-cc912c3b51be06a7034c397a2b77d7968a28a7bd.tar.gz nextcloud-server-cc912c3b51be06a7034c397a2b77d7968a28a7bd.zip |
Format lastActivity and type for plain output
Signed-off-by: Lucas Azevedo <lhs_azevedo@hotmail.com>
Diffstat (limited to 'core/Command')
-rw-r--r-- | core/Command/User/AuthTokens/ListCommand.php | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/core/Command/User/AuthTokens/ListCommand.php b/core/Command/User/AuthTokens/ListCommand.php index 97e94f29f92..bfc49606259 100644 --- a/core/Command/User/AuthTokens/ListCommand.php +++ b/core/Command/User/AuthTokens/ListCommand.php @@ -72,7 +72,7 @@ class ListCommand extends Base { $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']))); + $data = $this->formatTokenForPlainOutput($data); } return $data; @@ -82,4 +82,19 @@ class ListCommand extends Base { return 0; } + + public function formatTokenForPlainOutput(array $token): array { + $token['scope'] = implode(', ', array_keys(array_filter($token['scope'] ?? []))); + + $token['lastActivity'] = date(DATE_ATOM, $token['lastActivity']); + + $token['type'] = match ($token['type']) { + IToken::TEMPORARY_TOKEN => 'temporary', + IToken::PERMANENT_TOKEN => 'permanent', + IToken::WIPE_TOKEN => 'wipe', + default => $token['type'], + }; + + return $token; + } } |