Format lastActivity and type for plain output

Signed-off-by: Lucas Azevedo <lhs_azevedo@hotmail.com>
pull/40026/head
Lucas Azevedo 3 years ago
parent 9c66bf6dc3
commit cc912c3b51
  1. 17
      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;
}
}

Loading…
Cancel
Save