diff --git a/plugins/kolab_2fa/kolab2fa.js b/plugins/kolab_2fa/kolab2fa.js index dd0bf8b8..6fb3a4ff 100644 --- a/plugins/kolab_2fa/kolab2fa.js +++ b/plugins/kolab_2fa/kolab2fa.js @@ -56,17 +56,6 @@ window.rcmail && rcmail.addEventListener('init', function(evt) { }); table.parent()[(rows > 0 ? 'show' : 'hide')](); -/* - var remaining = 0; - $('#kolab2fa-add option').each(function(i, elem) { - var method = elem.value; - $(elem).prop('disabled', active[method]); - if (!active[method]) { - remaining++; - } - }); - $('#kolab2fa-add').prop('disabled', !remaining).get(0).selectedIndex = 0; -*/ } /** @@ -206,7 +195,9 @@ window.rcmail && rcmail.addEventListener('init', function(evt) { if (method) { highsec_call_stack.push(func); + // TODO: list all active factors to choose from var html = String($('#kolab2fa-highsecuritydialog').html()).replace('$name', name); + highsec_dialog = rcmail.show_popup_dialog( html, rcmail.get_label('highsecurityrequired', 'kolab_2fa'), @@ -339,8 +330,11 @@ window.rcmail && rcmail.addEventListener('init', function(evt) { $('#kolab2fa-add').change(function() { var method = $('option:selected', this).val(); - // require high security? - add_factor(method); + // require auth verification + require_high_security(function() { + add_factor(method); + }); + this.selectedIndex = 0; }); diff --git a/plugins/kolab_2fa/kolab_2fa.php b/plugins/kolab_2fa/kolab_2fa.php index 0d33bf2d..906b2b7d 100644 --- a/plugins/kolab_2fa/kolab_2fa.php +++ b/plugins/kolab_2fa/kolab_2fa.php @@ -621,10 +621,14 @@ class kolab_2fa extends rcube_plugin $driver->set('active', true); } - // update list of active factors for this user + // commit changes to the user properties if (!$errors) { - $success = $driver->commit(); - $save_data = $data !== false ? $this->format_props($driver->props()) : array(); + if ($success = $driver->commit()) { + $save_data = $data !== false ? $this->format_props($driver->props()) : array(); + } + else { + $errors++; + } } }