diff --git a/src/routes/UserRoutes.php b/src/routes/UserRoutes.php index 67f175e..97a16d2 100644 --- a/src/routes/UserRoutes.php +++ b/src/routes/UserRoutes.php @@ -217,7 +217,16 @@ public function addRoutes($router, $displayEngine, $api) { $router->post('/profile/add2fakey(\.json)?', function($json = NULL) use ($router, $displayEngine, $api) { if (!$this->checkAuthTimeOrError($displayEngine, $json)) { return; } - $apiresult = $api->create2FAKey(['description' => (isset($_POST['description']) ? $_POST['description'] : 'New 2FA Key: ' . date('Y-m-d H:i:s'))]); + $data = []; + $data['description'] = (isset($_POST['description']) ? $_POST['description'] : 'New 2FA Key: ' . date('Y-m-d H:i:s')); + + $data['type'] = isset($_POST['type']) ? strtolower($_POST['type']) : 'rfc6238'; + if ($data['type'] == 'onetime') { + $data['type'] = 'plain'; + $data['onetime'] = true; + } + + $apiresult = $api->create2FAKey($data); $result = ['unknown', 'unknown']; if (array_key_exists('error', $apiresult)) { diff --git a/templates/default/profile/2fakeys.tpl b/templates/default/profile/2fakeys.tpl index 9db8fa2..738c7ff 100644 --- a/templates/default/profile/2fakeys.tpl +++ b/templates/default/profile/2fakeys.tpl @@ -23,22 +23,36 @@ You will only be able to see the key and associated QR code for any keys that ha