feat: support LDAP's SetPassword (#3395)

* fix: Resolve the issue mentioned in #3392

* fix: Change checkLdapUserPassword to CheckLdapUserPassword.

* fix: the issue mentioned by hsluoyz.

* fix: Check if the user parameter is nil

* fix: use existing i18n message
This commit is contained in:
Xin-Fax
2024-12-09 17:06:24 +09:00
committed by GitHub
parent 01212cd1f3
commit b927c6d7b4
5 changed files with 85 additions and 5 deletions

View File

@ -273,7 +273,7 @@ func CheckPasswordComplexity(user *User, password string) string {
return CheckPasswordComplexityByOrg(organization, password)
}
func checkLdapUserPassword(user *User, password string, lang string) error {
func CheckLdapUserPassword(user *User, password string, lang string) error {
ldaps, err := GetLdaps(user.Owner)
if err != nil {
return err
@ -368,7 +368,7 @@ func CheckUserPassword(organization string, username string, password string, la
}
// only for LDAP users
err = checkLdapUserPassword(user, password, lang)
err = CheckLdapUserPassword(user, password, lang)
if err != nil {
if err.Error() == "user not exist" {
return nil, fmt.Errorf(i18n.Translate(lang, "check:The user: %s doesn't exist in LDAP server"), username)