Require 2nd factor verification for adding an new factor

This commit is contained in:
Thomas Bruederli 2015-06-11 17:16:46 +02:00
parent 3e52521c3e
commit f19f3f06c1
2 changed files with 14 additions and 16 deletions

View file

@ -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;
});

View file

@ -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++;
}
}
}