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
{{ keydata.key }} -
- {{ keydata.key }} + {% if keydata.type == 'rfc6238' %} +
+ {{ keydata.key }} + {% endif %}
- This key is not yet active, please activate the key by submitting a valid code from it -

-
- - + {% if keydata.type == 'rfc6238' %} + This key is not yet active, please activate the key by submitting a valid code from it

- -
+
+ + +

+ +
+ {% else %} + This key is not yet active. +

+
+ + + +
+ {% endif %}
+ {% elseif not keydata.usable %} + Hidden. (Key has expired) {% else %} - Hidden - key is active + Hidden. (Key is active) {% endif %} @@ -71,6 +85,10 @@ You will only be able to see the key and associated QR code for any keys that ha
+ Key Type: