diff --git a/src/ui/api/member.go b/src/ui/api/member.go index 07426a1be..0ac5e35af 100644 --- a/src/ui/api/member.go +++ b/src/ui/api/member.go @@ -166,21 +166,33 @@ func (pma *ProjectMemberAPI) Post() { if userID <= 0 { //check current authorization mode authMode, err := config.AuthMode() - if err != nil || authMode != "ldap_auth" { - log.Warningf("User does not exist, user name: %s", username) + if err != nil { + log.Errorf("Failed the retrieve auth_mode, error: %s", err) + pma.RenderError(http.StatusInternalServerError, "Failed to retrieve auth_mode") + return + } + + if authMode != "ldap_auth" { + log.Errorf("User does not exist, user name: %s", username) pma.RenderError(http.StatusNotFound, "User does not exist") return } //search and import user newUserID, err := ldapUtils.SearchAndImportUser(username) - if err == nil || newUserID > 0 { - userID = int(newUserID) - } else { - log.Warningf("User does not exist, user name: %s", username) - pma.RenderError(http.StatusNotFound, "User does not exist") + if err != nil { + log.Errorf("Search and import user failed, error: %v ", err) + pma.RenderError(http.StatusInternalServerError, "Failed to search and import user") return } + + if newUserID <= 0 { + log.Error("Failed to create user") + pma.RenderError(http.StatusNotFound, "Failed to create user") + return + } + + userID = int(newUserID) } rolelist, err := dao.GetUserProjectRoles(userID, projectID) if err != nil { diff --git a/src/ui/config/config.go b/src/ui/config/config.go index a70945df7..1609e82d3 100644 --- a/src/ui/config/config.go +++ b/src/ui/config/config.go @@ -185,7 +185,7 @@ func LDAP() (*models.LDAP, error) { if cfg[common.LDAPVerifyCert] != nil { ldap.VerifyCert = cfg[common.LDAPVerifyCert].(bool) } else { - ldap.VerifyCert = false + ldap.VerifyCert = true } return ldap, nil