From e9d72a6c10fb83d72551dcff3e166ddba774f045 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Sun, 1 May 2011 16:44:32 +0200 Subject: [PATCH] LSformElement :: password : Added support of verify feature for non login password --- .../class/class.LSformElement_password.php | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/public_html/includes/class/class.LSformElement_password.php b/public_html/includes/class/class.LSformElement_password.php index 8d8ba2ae..073761e3 100644 --- a/public_html/includes/class/class.LSformElement_password.php +++ b/public_html/includes/class/class.LSformElement_password.php @@ -60,14 +60,12 @@ class LSformElement_password extends LSformElement { return true; } - if (!isset($this -> params['html_options']['isLoginPassword']) || $this -> params['html_options']['isLoginPassword']) { - if ($this -> verifyPassword($return[$this -> name][0])) { - LSdebug("Password : no change"); - unset($return[$this -> name]); - $this -> form -> _notUpdate[$this -> name] == true; - return true; - } - } + if ($this -> verifyPassword($return[$this -> name][0])) { + LSdebug("Password : no change"); + unset($return[$this -> name]); + $this -> form -> _notUpdate[$this -> name] == true; + return true; + } //Mail if (isset($_POST['LSformElement_password_'.$this -> name.'_send'])) { @@ -164,7 +162,18 @@ class LSformElement_password extends LSformElement { if ($this -> attr_html -> attribute -> ldapObject -> isNew()) { return false; } - return LSsession :: checkUserPwd($this -> attr_html -> attribute -> ldapObject,$pwd); + if ($this -> isLoginPassword()) { + return LSsession :: checkUserPwd($this -> attr_html -> attribute -> ldapObject,$pwd); + } + else { + $hash = $this -> attr_html -> attribute -> ldap -> encodePassword($pwd); + $find=false; + foreach($this -> attr_html -> attribute -> data as $val) { + if ($hash == $val) + $find=true; + } + return $find; + } } function send($params) { @@ -258,6 +267,13 @@ class LSformElement_password extends LSformElement { } } + public function isLoginPassword() { + if (!isset($this -> params['html_options']['isLoginPassword']) || $this -> params['html_options']['isLoginPassword']) { + return true; + } + return false; + } + } ?>