I would rather each new signup get the same password like 123 than the overly complicated one moodle makes. They change it on first login anyway. Can anyone help me change the mechanism to generate simpler passwords?
Moodle created passwords made easier
Number of replies: 2Re: Moodle created passwords made easier
site admin menu => security -> site policy
but you are asking about generation, and not password difficulties...
my question is what type authentication are you using?
site admin menu -> plugins -> authentication -> manager
double checking that you are not using another type of authentication method. and passwords are generated in some other software.
in the old 1.x versions i remember password generation was in authentication files i want to say. but 2.x version of moodle not a clue.
little bit of hunting and i found...
www.yoursite.com/moodle/lib/password_compat/readme_moodle.txt
www.yoursite.com/moodle/lib/password_compat/lib/password.php the php file looks like it might have something... a bit to much to sink in at moment
www.yoursite.com/moodle/lib/moodlelib.php might have something in it as well
www.yoursite.com/moodle/config-dist.php has some extra info about passwords.
==================
KEY WORDS to search for = password, salt, crypt, encrypt, md5, hash might reveal some other files.
Re: Moodle created passwords made easier
Thank you for the feedback Ryan. My site policies are to let users decide what to change their passwords to. For authentication it is set to external database adn that is fine except the automatic password generation.
I looked at all of the pages you suggested and the moodlelib.php has a line that might fix the problem but I would like to get rid of the special characters too. Here is what I think is the relevant part I think on the first line I can change maxlen to 3 and it will make it far easier as long as the next moodle update does not overwrite my changes.:
function generate_password($maxlen=10) {
global $CFG;
if (empty($CFG->passwordpolicy)) {
$fillers = PASSWORD_DIGITS;
$wordlist = file($CFG->wordlist);
$word1 = trim($wordlist[rand(0, count($wordlist) - 1)]);
$word2 = trim($wordlist[rand(0, count($wordlist) - 1)]);
$filler1 = $fillers[rand(0, strlen($fillers) - 1)];
$password = $word1 . $filler1 . $word2;
} else {
$minlen = !empty($CFG->minpasswordlength) ? $CFG->minpasswordlength : 0;
$digits = $CFG->minpassworddigits;
$lower = $CFG->minpasswordlower;
$upper = $CFG->minpasswordupper;
$nonalphanum = $CFG->minpasswordnonalphanum;
$total = $lower + $upper + $digits + $nonalphanum;
// Var minlength should be the greater one of the two ( $minlen and $total ).
$minlen = $minlen < $total ? $total : $minlen;
// Var maxlen can never be smaller than minlen.
$maxlen = $minlen > $maxlen ? $minlen : $maxlen;
$additional = $maxlen - $total;
// Make sure we have enough characters to fulfill
// complexity requirements.
$passworddigits = PASSWORD_DIGITS;
while ($digits > strlen($passworddigits)) {
$passworddigits .= PASSWORD_DIGITS;
}
$passwordlower = PASSWORD_LOWER;
while ($lower > strlen($passwordlower)) {
$passwordlower .= PASSWORD_LOWER;
}
$passwordupper = PASSWORD_UPPER;
while ($upper > strlen($passwordupper)) {
$passwordupper .= PASSWORD_UPPER;
}
$passwordnonalphanum = PASSWORD_NONALPHANUM;
while ($nonalphanum > strlen($passwordnonalphanum)) {
$passwordnonalphanum .= PASSWORD_NONALPHANUM;
}
// Now mix and shuffle it all.
$password = str_shuffle (substr(str_shuffle ($passwordlower), 0, $lower) .
substr(str_shuffle ($passwordupper), 0, $upper) .
substr(str_shuffle ($passworddigits), 0, $digits) .
substr(str_shuffle ($passwordnonalphanum), 0 , $nonalphanum) .
substr(str_shuffle ($passwordlower .
$passwordupper .
$passworddigits .
$passwordnonalphanum), 0 , $additional));
}
return substr ($password, 0, $maxlen);
}