mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-22 16:33:48 +01:00
Fix historical typo lenght vs length
This commit is contained in:
parent
1a2fe50ba2
commit
425df3da3a
6 changed files with 35 additions and 18 deletions
|
@ -9,7 +9,7 @@
|
|||
'isLoginPassword' => [booleen],
|
||||
'generationTool' => [booleen],
|
||||
'autoGenerate' => [booleen],
|
||||
'lenght' => [nombre de caractères],
|
||||
'length' => [nombre de caractères],
|
||||
'chars' => array ( // Caractères que peut contenir le mot de passe
|
||||
array( // Liste caractère avec un nombre mininum d'apparition supérieur à 1
|
||||
'nb' => [nb caractères],
|
||||
|
@ -72,7 +72,7 @@
|
|||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>lenght</term>
|
||||
<term>length</term>
|
||||
<listitem>
|
||||
<simpara>Nombre de caractères que devront contenir les mots de passe générés.
|
||||
</simpara>
|
||||
|
|
|
@ -542,7 +542,7 @@ $GLOBALS['LSobjects']['LSpeople'] = array (
|
|||
'viewHash' => true,
|
||||
'autoGenerate' => false,
|
||||
'confirmInput' => true,
|
||||
'lenght' => 8,
|
||||
'length' => 8,
|
||||
'chars' => array (
|
||||
array(
|
||||
'nb' => 3,
|
||||
|
|
|
@ -135,7 +135,7 @@ $GLOBALS['LSobjects']['LSsysaccount'] = array (
|
|||
'generationTool' => true,
|
||||
'viewHash' => true,
|
||||
'autoGenerate' => false,
|
||||
'lenght' => 12,
|
||||
'length' => 12,
|
||||
'chars' => array (
|
||||
array(
|
||||
'nb' => 3,
|
||||
|
|
|
@ -261,7 +261,13 @@ class LSformElement_password extends LSformElement {
|
|||
public static function generatePassword($params=NULL) {
|
||||
if (LSconfig :: get('html_options.use_pwgen', false, null, $params)) {
|
||||
$args = LSconfig :: get('html_options.pwgen_opts', '', 'string', $params);
|
||||
$len = LSconfig :: get('html_options.lenght', 8, 'int', $params);
|
||||
$len = LSconfig :: get(
|
||||
'html_options.length',
|
||||
// Keep compatibility with historical typo (lenght vs length)
|
||||
LSconfig :: get('html_options.lenght', 8, 'int', $params),
|
||||
'int',
|
||||
$params
|
||||
);
|
||||
$bin = LSconfig :: get('html_options.pwgen_path', 'pwgen', 'string', $params);
|
||||
$cmd = "$bin ".escapeshellcmd($args)." $len 1";
|
||||
exec($cmd,$ret,$retcode);
|
||||
|
@ -275,7 +281,13 @@ class LSformElement_password extends LSformElement {
|
|||
}
|
||||
return generatePassword(
|
||||
LSconfig :: get('html_options.chars', null, null, $params),
|
||||
LSconfig :: get('html_options.lenght', 8, 'int', $params)
|
||||
LSconfig :: get(
|
||||
'html_options.length',
|
||||
// Keep compatibility with historical typo (lenght vs length)
|
||||
LSconfig :: get('html_options.lenght', 8, 'int', $params),
|
||||
'int',
|
||||
$params
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1200,10 +1200,15 @@ class LSsession {
|
|||
$pwd_attr_name = LSauth :: getUserPasswordAttribute($user);
|
||||
if (array_key_exists($pwd_attr_name, $user -> attrs)) {
|
||||
$pwd_attr = $user -> attrs[$pwd_attr_name];
|
||||
$pwd = generatePassword(
|
||||
$pwd_attr -> getConfig('html_options.chars'),
|
||||
$pwd_attr -> getConfig('html_options.lenght')
|
||||
);
|
||||
if (self :: loadLSclass('LSformElement_password')) {
|
||||
$pwd = LSformElement_password :: generatePassword($pwd_attr->config);
|
||||
}
|
||||
else {
|
||||
$pwd = generatePassword(
|
||||
$pwd_attr -> getConfig('html_options.chars'),
|
||||
$pwd_attr -> getConfig('html_options.length')
|
||||
);
|
||||
}
|
||||
self :: log_debug("recoverPasswdSecondStep($user): new password = '$pwd'.");
|
||||
$lostPasswdForm = $user -> getForm('lostPassword');
|
||||
$lostPasswdForm -> setPostData(
|
||||
|
|
|
@ -477,9 +477,9 @@ function checkEmail($value,$domain=NULL,$checkDns=true) {
|
|||
return true;
|
||||
}
|
||||
|
||||
function generatePassword($chars=NULL,$lenght=NULL) {
|
||||
if (!$lenght) {
|
||||
$lenght=8;
|
||||
function generatePassword($chars=NULL,$length=NULL) {
|
||||
if (!$length) {
|
||||
$length=8;
|
||||
}
|
||||
if (is_array($chars)) {
|
||||
$retval='';
|
||||
|
@ -492,17 +492,17 @@ function generatePassword($chars=NULL,$lenght=NULL) {
|
|||
}
|
||||
$retval.=aleaChar($chs['chars'],$chs['nb']);
|
||||
}
|
||||
$add = ($lenght-strlen($retval));
|
||||
$add = ($length-strlen($retval));
|
||||
if ($add > 0) {
|
||||
$retval .= aleaChar($chars,$add);
|
||||
}
|
||||
return str_shuffle($retval);
|
||||
} else {
|
||||
return aleaChar($chars,$lenght);
|
||||
return aleaChar($chars,$length);
|
||||
}
|
||||
}
|
||||
|
||||
function aleaChar($chars=NULL,$lenght=1) {
|
||||
function aleaChar($chars=NULL,$length=1) {
|
||||
if (is_array($chars)) {
|
||||
$nchars="";
|
||||
foreach($chars as $chs) {
|
||||
|
@ -525,8 +525,8 @@ function aleaChar($chars=NULL,$lenght=1) {
|
|||
}
|
||||
$nbChars=strlen($chars);
|
||||
$retval="";
|
||||
if(is_int($lenght)) {
|
||||
for ($i=0;$i<$lenght;$i++) {
|
||||
if(is_int($length)) {
|
||||
for ($i=0;$i<$length;$i++) {
|
||||
$retval.=$chars[rand(0,$nbChars-1)];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue