summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2020-11-10 13:18:13 +0100
committerBenjamin Brahmer <info@b-brahmer.de>2020-11-10 16:47:42 +0100
commit7effe4654b8243e0ca4dd9c4fa13ac53203c28b2 (patch)
tree1020b36cbd81c225bfeab8c758fa4be6eb6c298c /lib
parent5bdc2df7f484f6618919a63247045027d43b78f7 (diff)
Unremove but deprecate User API
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'lib')
-rw-r--r--lib/Controller/UserApiController.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/Controller/UserApiController.php b/lib/Controller/UserApiController.php
new file mode 100644
index 000000000..f5137992d
--- /dev/null
+++ b/lib/Controller/UserApiController.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Nextcloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Alessandro Cosentino <cosenal@gmail.com>
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @author David Guillot <david@guillot.me>
+ * @copyright 2012 Alessandro Cosentino
+ * @copyright 2012-2014 Bernhard Posselt
+ * @copyright 2018 David Guillot
+ */
+
+namespace OCA\News\Controller;
+
+use \OCP\IRequest;
+use \OCP\IUserSession;
+use \OCP\IURLGenerator;
+use \OCP\Files\IRootFolder;
+use \OCP\AppFramework\Http;
+
+class UserApiController extends ApiController
+{
+ public function __construct(
+ string $appName,
+ IRequest $request,
+ IUserSession $userSession
+ ) {
+ parent::__construct($appName, $request, $userSession);
+ }
+
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ *
+ * @deprecated Should use https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-api-overview.html#user-metadata
+ * and avatar is `https://nc.url/avatar/{userid}/{size}?v={1|2}`
+ */
+ public function index(): array
+ {
+ $user = $this->getUser();
+ $avatar = null;
+
+ return [
+ 'userId' => $user->getUID(),
+ 'displayName' => $user->getDisplayName(),
+ 'lastLoginTimestamp' => $user->getLastLogin(),
+ 'avatar' => $avatar
+ ];
+ }
+}