diff --git a/htdocs/lib/User/User.php b/htdocs/lib/User/User.php index 330e697..b873f5e 100644 --- a/htdocs/lib/User/User.php +++ b/htdocs/lib/User/User.php @@ -139,7 +139,7 @@ class User { public function isPasswordCorrect($inputPasswd){ $passUtil = new Util\Password(); $this_passwd = $this->queryResultArray['password']; - return $passUtil->checkSame($this_passwd, $inputPasswd); + return $passUtil->checkSameTryAll($this_passwd, $inputPasswd); } /** diff --git a/htdocs/lib/User/UserAdmin.php b/htdocs/lib/User/UserAdmin.php index af7a733..b63cc28 100644 --- a/htdocs/lib/User/UserAdmin.php +++ b/htdocs/lib/User/UserAdmin.php @@ -53,8 +53,6 @@ class UserAdmin { * @param array $userInfoArray 使用者資訊陣列,格式為: * array( 'user_id' => 'root', * 'password' => 'pass123', - * 'password_encrypt' => null, // (optional) 預設為null - * 'password_encrypted' => null, // (optional) 預設為false * 'group_id' => 'user', * 'class_id' => '5-2', // (optional) * 'enable' => true, // (optional) 預設為true diff --git a/htdocs/lib/Util/Password.php b/htdocs/lib/Util/Password.php index 37ec503..afa1b82 100644 --- a/htdocs/lib/Util/Password.php +++ b/htdocs/lib/Util/Password.php @@ -104,7 +104,7 @@ class Password { } /** - * 加密這段字 + * 確認是否吻合 * * @param string $encrypted 已加密字串 * @param string $text 原本字串 @@ -124,6 +124,28 @@ class Password { } } + /** + * 確認所有的加密法是否吻合 + * + * @param string $encrypted 已加密字串 + * @param string $text 原本字串 + * @return bool true代表與加密後字串一樣 + * @since 2.0.0 + */ + public function checkSameTryAll($encrypted, $text) { + // 判斷是否吻合 + switch($encrypted) { + case $this->encrypt($text): + case $text: + case $this->sha1Encrypt($text): + case $this->md5Encrypt($text): + case $this->cryptEncrypt($text): + return true; + default: + return false; + } + } + // ------------------------------------------------------------------------ /**