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