diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-05-07 20:29:51 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-05-08 09:44:51 +0200 |
commit | 278c281cc9c03ad060ac6a91784058066411c7a8 (patch) | |
tree | d82e5fda75a9811bc2e280f3933cc36a99ff9e4b /core/src/OC | |
parent | a3800a6810fca68eff1789dc21488389bf22108a (diff) | |
download | nextcloud-server-278c281cc9c03ad060ac6a91784058066411c7a8.tar.gz nextcloud-server-278c281cc9c03ad060ac6a91784058066411c7a8.zip |
Deprecate oc_current_user, fix usage and move currentUser to the bundle
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'core/src/OC')
-rw-r--r-- | core/src/OC/currentuser.js | 36 | ||||
-rw-r--r-- | core/src/OC/index.js | 15 |
2 files changed, 51 insertions, 0 deletions
diff --git a/core/src/OC/currentuser.js b/core/src/OC/currentuser.js new file mode 100644 index 00000000000..f1ab140376d --- /dev/null +++ b/core/src/OC/currentuser.js @@ -0,0 +1,36 @@ +/* + * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +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, + } +} diff --git a/core/src/OC/index.js b/core/src/OC/index.js index 9ac9be05e60..a27695d8eda 100644 --- a/core/src/OC/index.js +++ b/core/src/OC/index.js @@ -37,6 +37,7 @@ import { TAG_FAVORITE, } from './constants' import ContactsMenu from './contactsmenu' +import {currentUser, getCurrentUser} from './currentuser' import Dialogs from './dialogs' import EventSource from './eventsource' import {get, set} from './get_set' @@ -90,8 +91,22 @@ export default { Backbone, ContactsMenu, config: Config, + /** + * Currently logged in user or null if none + * + * @type String + * @deprecated use {@link OC.getCurrentUser} instead + */ + currentUser, dialogs: Dialogs, EventSource, + /** + * Returns the currently logged in user or null if there is no logged in + * user (public page mode) + * + * @since 9.0.0 + */ + getCurrentUser, isUserAdmin, L10N, |