mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-21342 add user login lockout
This commit is contained in:
parent
0dc5a532ec
commit
b28247fe90
13 changed files with 550 additions and 49 deletions
|
@ -59,6 +59,11 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
|||
$temp->add(new admin_setting_configcheckbox('cronclionly', new lang_string('cronclionly', 'admin'), new lang_string('configcronclionly', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configpasswordunmask('cronremotepassword', new lang_string('cronremotepassword', 'admin'), new lang_string('configcronremotepassword', 'admin'), ''));
|
||||
|
||||
$options = array(0=>get_string('no'), 3=>3, 5=>5, 7=>7, 10=>10, 20=>20, 30=>30, 50=>50, 100=>100);
|
||||
$temp->add(new admin_setting_configselect('lockoutthreshold', new lang_string('lockoutthreshold', 'admin'), new lang_string('lockoutthreshold_desc', 'admin'), 0, $options));
|
||||
$temp->add(new admin_setting_configduration('lockoutwindow', new lang_string('lockoutwindow', 'admin'), new lang_string('lockoutwindow_desc', 'admin'), 60*30));
|
||||
$temp->add(new admin_setting_configduration('lockoutduration', new lang_string('lockoutduration', 'admin'), new lang_string('lockoutduration_desc', 'admin'), 60*30));
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('passwordpolicy', new lang_string('passwordpolicy', 'admin'), new lang_string('configpasswordpolicy', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configtext('minpasswordlength', new lang_string('minpasswordlength', 'admin'), new lang_string('configminpasswordlength', 'admin'), 8, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('minpassworddigits', new lang_string('minpassworddigits', 'admin'), new lang_string('configminpassworddigits', 'admin'), 1, PARAM_INT));
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/authlib.php');
|
||||
require_once($CFG->dirroot.'/user/filters/lib.php');
|
||||
|
||||
$delete = optional_param('delete', 0, PARAM_INT);
|
||||
|
@ -16,6 +17,7 @@
|
|||
$acl = optional_param('acl', '0', PARAM_INT); // id of user to tweak mnet ACL (requires $access)
|
||||
$suspend = optional_param('suspend', 0, PARAM_INT);
|
||||
$unsuspend = optional_param('unsuspend', 0, PARAM_INT);
|
||||
$unlock = optional_param('unlock', 0, PARAM_INT);
|
||||
|
||||
admin_externalpage_setup('editusers');
|
||||
|
||||
|
@ -32,6 +34,7 @@
|
|||
$strshowallusers = get_string('showallusers');
|
||||
$strsuspend = get_string('suspenduser', 'admin');
|
||||
$strunsuspend = get_string('unsuspenduser', 'admin');
|
||||
$strunlock = get_string('unlockaccount', 'admin');
|
||||
$strconfirm = get_string('confirm');
|
||||
|
||||
if (empty($CFG->loginhttps)) {
|
||||
|
@ -143,6 +146,14 @@
|
|||
}
|
||||
}
|
||||
redirect($returnurl);
|
||||
|
||||
} else if ($unlock and confirm_sesskey()) {
|
||||
require_capability('moodle/user:update', $sitecontext);
|
||||
|
||||
if ($user = $DB->get_record('user', array('id'=>$unlock, 'mnethostid'=>$CFG->mnet_localhost_id, 'deleted'=>0))) {
|
||||
login_unlock_account($user);
|
||||
}
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
// create the user filter form
|
||||
|
@ -303,6 +314,9 @@
|
|||
}
|
||||
}
|
||||
|
||||
if (login_is_lockedout($user)) {
|
||||
$buttons[] = html_writer::link(new moodle_url($returnurl, array('unlock'=>$user->id, 'sesskey'=>sesskey())), html_writer::empty_tag('img', array('src'=>$OUTPUT->pix_url('t/unlock'), 'alt'=>$strunlock, 'class'=>'iconsmall')), array('title'=>$strunlock));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue