改良密碼驗證: 改成會嘗試所有的加密法
This commit is contained in:
parent
01ddc82f59
commit
6915818678
@ -139,7 +139,7 @@ class User {
|
|||||||
public function isPasswordCorrect($inputPasswd){
|
public function isPasswordCorrect($inputPasswd){
|
||||||
$passUtil = new Util\Password();
|
$passUtil = new Util\Password();
|
||||||
$this_passwd = $this->queryResultArray['password'];
|
$this_passwd = $this->queryResultArray['password'];
|
||||||
return $passUtil->checkSame($this_passwd, $inputPasswd);
|
return $passUtil->checkSameTryAll($this_passwd, $inputPasswd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,8 +53,6 @@ class UserAdmin {
|
|||||||
* @param array $userInfoArray 使用者資訊陣列,格式為:
|
* @param array $userInfoArray 使用者資訊陣列,格式為:
|
||||||
* array( 'user_id' => 'root',
|
* array( 'user_id' => 'root',
|
||||||
* 'password' => 'pass123',
|
* 'password' => 'pass123',
|
||||||
* 'password_encrypt' => null, // (optional) 預設為null
|
|
||||||
* 'password_encrypted' => null, // (optional) 預設為false
|
|
||||||
* 'group_id' => 'user',
|
* 'group_id' => 'user',
|
||||||
* 'class_id' => '5-2', // (optional)
|
* 'class_id' => '5-2', // (optional)
|
||||||
* 'enable' => true, // (optional) 預設為true
|
* 'enable' => true, // (optional) 預設為true
|
||||||
|
@ -104,7 +104,7 @@ class Password {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加密這段字
|
* 確認是否吻合
|
||||||
*
|
*
|
||||||
* @param string $encrypted 已加密字串
|
* @param string $encrypted 已加密字串
|
||||||
* @param string $text 原本字串
|
* @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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user