diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-02-01 15:11:42 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-02-02 18:01:15 +0100 |
commit | 3b581b051f33e141ba0c76c8bcde104ce65826c2 (patch) | |
tree | f53fdf228a7266f9adf60f7ed61bbcd36fad38da /core/js/js.js | |
parent | 67a36a2cca65df4d4775e9ae5e1c0e51172ae081 (diff) | |
download | nextcloud-server-3b581b051f33e141ba0c76c8bcde104ce65826c2.tar.gz nextcloud-server-3b581b051f33e141ba0c76c8bcde104ce65826c2.zip |
Expose display name in JS side
Adds a new method `OC.getCurrentUser` to get both the user id and
display name Could be used for a future Js
Diffstat (limited to 'core/js/js.js')
-rw-r--r-- | core/js/js.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/core/js/js.js b/core/js/js.js index 43ea269c203..bc8c51e40d3 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -82,6 +82,12 @@ var OC={ webroot:oc_webroot, appswebroots:(typeof oc_appswebroots !== 'undefined') ? oc_appswebroots:false, + /** + * Currently logged in user or null if none + * + * @type String + * @deprecated use {@link OC.getCurrentUser} instead + */ currentUser:(typeof oc_current_user!=='undefined')?oc_current_user:false, config: window.oc_config, appConfig: window.oc_appconfig || {}, @@ -272,6 +278,23 @@ var OC={ }, /** + * Returns the currently logged in user or null if there is no logged in + * user (public page mode) + * + * @return {OC.CurrentUser} user spec + * @since 9.0.0 + */ + getCurrentUser: function() { + if (_.isUndefined(this._currentUserDisplayName)) { + this._currentUserDisplayName = document.getElementsByTagName('head')[0].getAttribute('data-user-displayname'); + } + return { + uid: this.currentUser, + displayName: this._currentUserDisplayName + }; + }, + + /** * get the absolute path to an image file * if no extension is given for the image, it will automatically decide * between .png and .svg based on what the browser supports @@ -690,6 +713,15 @@ var OC={ }; /** + * Current user attributes + * + * @typedef {Object} OC.CurrentUser + * + * @property {String} uid user id + * @property {String} displayName display name + */ + +/** * @namespace OC.Plugins */ OC.Plugins = { |