diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2017-03-14 17:12:01 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2017-04-10 09:14:52 +0300 |
commit | 16f760d49ea6b9f37aaeaacaf3f29fe56159831b (patch) | |
tree | 1869383b6b12a07575ce72e92459296f0dd4d21c /lib/Controller | |
parent | 1d7d5f07871f764ff4cfb25ae66c247f9841a06e (diff) |
Add possibility to add multiple U2F devices
Users should be able to add as many devices as they like, hence
the interface should allow to list added devices and have a button
to add new ones. To identify devices later, users can give names
to devices.
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/Controller')
-rw-r--r-- | lib/Controller/SettingsController.php | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index bcd8992..d55dbc3 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -16,6 +16,7 @@ require_once(__DIR__ . '/../../vendor/yubico/u2flib-server/src/u2flib_server/U2F use OCA\TwoFactorU2F\Service\U2FManager; use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; use OCP\IUserSession; @@ -41,39 +42,46 @@ class SettingsController extends Controller { /** * @NoAdminRequired + * @return JSONResponse */ public function state() { return [ - 'enabled' => $this->manager->isEnabled($this->userSession->getUser()) + 'devices' => $this->manager->getDevices($this->userSession->getUser()) ]; } /** * @NoAdminRequired * @PasswordConfirmationRequired + * @UseSession + * @return JSONResponse */ - public function disable() { - $this->manager->disableU2F($this->userSession->getUser()); + public function startRegister() { + return $this->manager->startRegistration($this->userSession->getUser()); } /** * @NoAdminRequired * @PasswordConfirmationRequired - * @UseSession + * + * @param string $registrationData + * @param string $clientData + * @param string|null $name device name, given by user + * @return JSONResponse */ - public function startRegister() { - return $this->manager->startRegistration($this->userSession->getUser()); + public function finishRegister($registrationData, $clientData, $name = null) { + return $this->manager->finishRegistration($this->userSession->getUser(), $registrationData, $clientData, $name); } /** * @NoAdminRequired * @PasswordConfirmationRequired * - * @param string $registrationData - * @param string $clientData + * @param int $id + * @return JSONResponse */ - public function finishRegister($registrationData, $clientData) { - $this->manager->finishRegistration($this->userSession->getUser(), $registrationData, $clientData); + public function remove($id) { + return $this->manager->removeDevice($this->userSession->getUser(), $id); } } |