mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 12:15:20 +01:00
Merge pull request #1960 from ywk253100/170407_role
Donot add projectadmin role to sysadmin when return roles, fix #1957
This commit is contained in:
commit
9327fd2c66
@ -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 {
|
roles, err := dao.GetUserProjectRoles(p.userID, projectList[i].ProjectID)
|
||||||
projectList[i].Role = models.PROJECTADMIN
|
if err != nil {
|
||||||
} else {
|
log.Errorf("failed to get user's project role: %v", err)
|
||||||
roles, err := dao.GetUserProjectRoles(p.userID, projectList[i].ProjectID)
|
p.CustomAbort(http.StatusInternalServerError, "")
|
||||||
if err != nil {
|
|
||||||
log.Errorf("failed to get user's project role: %v", err)
|
|
||||||
p.CustomAbort(http.StatusInternalServerError, "")
|
|
||||||
}
|
|
||||||
projectList[i].Role = roles[0].RoleID
|
|
||||||
}
|
}
|
||||||
if projectList[i].Role == models.PROJECTADMIN {
|
projectList[i].Role = roles[0].RoleID
|
||||||
|
if projectList[i].Role == models.PROJECTADMIN ||
|
||||||
|
isAdmin {
|
||||||
projectList[i].Togglable = true
|
projectList[i].Togglable = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,20 +78,16 @@ func (s *SearchAPI) Get() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if userID != dao.NonExistUserID {
|
if userID != dao.NonExistUserID {
|
||||||
if isSysAdmin {
|
roles, err := dao.GetUserProjectRoles(userID, p.ProjectID)
|
||||||
p.Role = models.PROJECTADMIN
|
if err != nil {
|
||||||
} else {
|
log.Errorf("failed to get user's project role: %v", err)
|
||||||
roles, err := dao.GetUserProjectRoles(userID, p.ProjectID)
|
s.CustomAbort(http.StatusInternalServerError, "")
|
||||||
if err != nil {
|
}
|
||||||
log.Errorf("failed to get user's project role: %v", err)
|
if len(roles) != 0 {
|
||||||
s.CustomAbort(http.StatusInternalServerError, "")
|
p.Role = roles[0].RoleID
|
||||||
}
|
|
||||||
if len(roles) != 0 {
|
|
||||||
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