aboutsummaryrefslogtreecommitdiffstats
path: root/core/src/OC/currentuser.js
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/OC/currentuser.js')
-rw-r--r--core/src/OC/currentuser.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/core/src/OC/currentuser.js b/core/src/OC/currentuser.js
new file mode 100644
index 00000000000..a022698eab0
--- /dev/null
+++ b/core/src/OC/currentuser.js
@@ -0,0 +1,20 @@
+/**
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+const rawUid = document
+ .getElementsByTagName('head')[0]
+ .getAttribute('data-user')
+const displayName = document
+ .getElementsByTagName('head')[0]
+ .getAttribute('data-user-displayname')
+
+export const currentUser = rawUid !== undefined ? rawUid : false
+
+export const getCurrentUser = () => {
+ return {
+ uid: currentUser,
+ displayName,
+ }
+}