mirror of
https://github.com/casdoor/casdoor.git
synced 2025-09-08 04:00:51 +08:00
feat: keep backward compatibility in GetHashedPassword()
This commit is contained in:
@@ -41,9 +41,17 @@ func (cm *Md5UserSaltCredManager) GetHashedPassword(password string, salt string
|
||||
if salt == "" {
|
||||
return getMd5HexDigest(password)
|
||||
}
|
||||
|
||||
return getMd5HexDigest(getMd5HexDigest(password) + salt)
|
||||
}
|
||||
|
||||
func (cm *Md5UserSaltCredManager) IsPasswordCorrect(plainPwd string, hashedPwd string, salt string) bool {
|
||||
// For backward-compatibility
|
||||
if salt == "" {
|
||||
if hashedPwd == cm.GetHashedPassword(getMd5HexDigest(plainPwd), salt) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return hashedPwd == cm.GetHashedPassword(plainPwd, salt)
|
||||
}
|
||||
|
Reference in New Issue
Block a user