Skip to content

Commit

Permalink
MDL-14092: forcing imported users with a weak password to change it o…
Browse files Browse the repository at this point in the history
…n first login.
  • Loading branch information
scyrma committed Sep 26, 2008
1 parent 9358613 commit a17718a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion admin/uploaduser.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@
$renameerrors = 0;
$usersskipped = 0;

$forcechangepassword = 0;

// caches
$ccache = array(); // course cache - do not fetch all courses here, we will not probably use them all anyway!
$rolecache = array(); // roles lookup cache
Expand Down Expand Up @@ -201,6 +203,9 @@
if ($key == 'password') {
if ($value !== '') {
$user->password = hash_internal_user_password($value);
if (!empty($CFG->passwordpolicy) and !check_password_policy($value, $errmsg)) {
$forcechangepassword++;
}
}
} else {
$user->$key = $value;
Expand Down Expand Up @@ -435,6 +440,9 @@
continue;
} else if (!empty($user->password)) {
$upt->track('password', get_string('updated'));
if ($forcechangepassword) {
set_user_preference('auth_forcepasswordchange', 1, $existinguser->id);
}
}
}
if ((array_key_exists($column, $existinguser) and array_key_exists($column, $user)) or in_array($column, $PRF_FIELDS)) {
Expand Down Expand Up @@ -538,6 +546,9 @@
set_user_preference('auth_forcepasswordchange', 1, $user->id);
$upt->track('password', get_string('new'));
}
if ($forcechangepassword) {
set_user_preference('auth_forcepasswordchange', 1, $user->id);
}
} else {
// Record not added -- possibly some other error
$upt->track('status', $strusernotaddederror, 'error');
Expand Down Expand Up @@ -696,6 +707,7 @@
if ($usersskipped) {
echo get_string('usersskipped', 'admin').': '.$usersskipped.'<br />';
}
echo get_string('usersweakpassword', 'admin').': '.$forcechangepassword.'<br />';
echo get_string('errors', 'admin').': '.$userserrors.'</p>';
print_box_end();

Expand Down Expand Up @@ -979,4 +991,4 @@ function uu_allowed_roles($shortname=false) {

return $choices;
}
?>
?>
1 change: 1 addition & 0 deletions lang/en_utf8/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@
$string['users'] = 'Users';
$string['userscreated'] = 'Users created';
$string['usersdeleted'] = 'Users deleted';
$string['usersweakpassword'] = 'Users having a weak password';
$string['usersrenamed'] = 'Users renamed';
$string['usersskipped'] = 'Users skipped';
$string['usersupdated'] = 'Users updated';
Expand Down

0 comments on commit a17718a

Please sign in to comment.