feat: keep backward compatibility in GetHashedPassword()

This commit is contained in:
Yang Luo
2025-07-21 19:32:59 +08:00
parent 65ab36f073
commit e05fbec739
3 changed files with 24 additions and 0 deletions

View File

@@ -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)
}