aboutsummaryrefslogtreecommitdiffstats
path: root/core/Command/User/Info.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/Command/User/Info.php')
-rw-r--r--core/Command/User/Info.php17
1 files changed, 15 insertions, 2 deletions
diff --git a/core/Command/User/Info.php b/core/Command/User/Info.php
index 55298f0164c..e7fc9286e74 100644
--- a/core/Command/User/Info.php
+++ b/core/Command/User/Info.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -6,6 +7,7 @@
namespace OC\Core\Command\User;
use OC\Core\Command\Base;
+use OCP\Files\NotFoundException;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserManager;
@@ -56,7 +58,8 @@ class Info extends Base {
'groups' => $groups,
'quota' => $user->getQuota(),
'storage' => $this->getStorageInfo($user),
- 'last_seen' => date(\DateTimeInterface::ATOM, $user->getLastLogin()), // ISO-8601
+ 'first_seen' => $this->formatLoginDate($user->getFirstLogin()),
+ 'last_seen' => $this->formatLoginDate($user->getLastLogin()),
'user_directory' => $user->getHome(),
'backend' => $user->getBackendClassName()
];
@@ -64,6 +67,16 @@ class Info extends Base {
return 0;
}
+ private function formatLoginDate(int $timestamp): string {
+ if ($timestamp < 0) {
+ return 'unknown';
+ } elseif ($timestamp === 0) {
+ return 'never';
+ } else {
+ return date(\DateTimeInterface::ATOM, $timestamp); // ISO-8601
+ }
+ }
+
/**
* @param IUser $user
* @return array
@@ -73,7 +86,7 @@ class Info extends Base {
\OC_Util::setupFS($user->getUID());
try {
$storage = \OC_Helper::getStorageInfo('/');
- } catch (\OCP\Files\NotFoundException $e) {
+ } catch (NotFoundException $e) {
return [];
}
return [