mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 18:25:56 +01:00
Update with PR review comment
This commit is contained in:
parent
16243cfbbc
commit
1179769e31
@ -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 {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user