diff options
author | Christoph Wurst <christoph@owncloud.com> | 2016-05-18 12:03:22 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@owncloud.com> | 2016-05-23 09:11:12 +0200 |
commit | 12431aa3997154aaea4eec11c2dd65f9e5dbe179 (patch) | |
tree | 8395c270b144401f53e5ed048f94a28002410e3d /settings/Controller | |
parent | 357d342467b9200f190376a2bd224fa7b803b45a (diff) | |
download | nextcloud-server-12431aa3997154aaea4eec11c2dd65f9e5dbe179.tar.gz nextcloud-server-12431aa3997154aaea4eec11c2dd65f9e5dbe179.zip |
list user's auth tokens on the personal settings page
Diffstat (limited to 'settings/Controller')
-rw-r--r-- | settings/Controller/AuthSettingsController.php | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/settings/Controller/AuthSettingsController.php b/settings/Controller/AuthSettingsController.php new file mode 100644 index 00000000000..1d874193d36 --- /dev/null +++ b/settings/Controller/AuthSettingsController.php @@ -0,0 +1,71 @@ +<?php + +/** + * @author Christoph Wurst <christoph@owncloud.com> + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * 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, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ + +namespace OC\Settings\Controller; + +use OC\Authentication\Token\IProvider; +use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\JSONResponse; +use OCP\IRequest; +use OCP\IUserManager; + +class AuthSettingsController extends Controller { + + /** @var IProvider */ + private $tokenProvider; + + /** + * @var IUserManager + */ + private $userManager; + + /** @var string */ + private $uid; + + /** + * @param string $appName + * @param IRequest $request + * @param IProvider $tokenProvider + * @param IUserManager $userManager + * @param string $uid + */ + public function __construct($appName, IRequest $request, IProvider $tokenProvider, IUserManager $userManager, $uid) { + parent::__construct($appName, $request); + $this->tokenProvider = $tokenProvider; + $this->userManager = $userManager; + $this->uid = $uid; + } + + /** + * @NoAdminRequired + * + * @return JSONResponse + */ + public function index() { + $user = $this->userManager->get($this->uid); + if (is_null($user)) { + return []; + } + return $this->tokenProvider->getTokenByUser($user); + } + +} |