mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 20:26:13 +01:00
donot add projectadmin role to sysadmin when return roles, fix #1957
This commit is contained in:
parent
afdbcc2b62
commit
746667bb38
@ -297,17 +297,14 @@ func (p *ProjectAPI) List() {
|
|||||||
|
|
||||||
for i := 0; i < len(projectList); i++ {
|
for i := 0; i < len(projectList); i++ {
|
||||||
if public != 1 {
|
if public != 1 {
|
||||||
if isAdmin {
|
|
||||||
projectList[i].Role = models.PROJECTADMIN
|
|
||||||
} else {
|
|
||||||
roles, err := dao.GetUserProjectRoles(p.userID, projectList[i].ProjectID)
|
roles, err := dao.GetUserProjectRoles(p.userID, projectList[i].ProjectID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("failed to get user's project role: %v", err)
|
log.Errorf("failed to get user's project role: %v", err)
|
||||||
p.CustomAbort(http.StatusInternalServerError, "")
|
p.CustomAbort(http.StatusInternalServerError, "")
|
||||||
}
|
}
|
||||||
projectList[i].Role = roles[0].RoleID
|
projectList[i].Role = roles[0].RoleID
|
||||||
}
|
if projectList[i].Role == models.PROJECTADMIN ||
|
||||||
if projectList[i].Role == models.PROJECTADMIN {
|
isAdmin {
|
||||||
projectList[i].Togglable = true
|
projectList[i].Togglable = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,9 +78,6 @@ func (s *SearchAPI) Get() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if userID != dao.NonExistUserID {
|
if userID != dao.NonExistUserID {
|
||||||
if isSysAdmin {
|
|
||||||
p.Role = models.PROJECTADMIN
|
|
||||||
} else {
|
|
||||||
roles, err := dao.GetUserProjectRoles(userID, p.ProjectID)
|
roles, err := dao.GetUserProjectRoles(userID, p.ProjectID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("failed to get user's project role: %v", err)
|
log.Errorf("failed to get user's project role: %v", err)
|
||||||
@ -89,9 +86,8 @@ func (s *SearchAPI) Get() {
|
|||||||
if len(roles) != 0 {
|
if len(roles) != 0 {
|
||||||
p.Role = roles[0].RoleID
|
p.Role = roles[0].RoleID
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if p.Role == models.PROJECTADMIN {
|
if p.Role == models.PROJECTADMIN || isSysAdmin {
|
||||||
p.Togglable = true
|
p.Togglable = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user