mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-08 17:08:17 +01:00
bug fix
This commit is contained in:
parent
ae77753bf2
commit
df56010739
@ -411,7 +411,7 @@ func TestListUsers(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("Error occurred in ListUsers: %v", err)
|
||||
}
|
||||
if len(users) != 2 {
|
||||
if len(users) != 1 {
|
||||
t.Errorf("Expect one user in list, but the acutal length is %d, the list: %+v", len(users), users)
|
||||
}
|
||||
users2, err := ListUsers(&models.UserQuery{Username: username})
|
||||
|
@ -109,7 +109,9 @@ func ListUsers(query *models.UserQuery) ([]models.User, error) {
|
||||
}
|
||||
|
||||
func userQueryConditions(query *models.UserQuery) orm.QuerySeter {
|
||||
qs := GetOrmer().QueryTable(&models.User{}).Filter("deleted", 0)
|
||||
qs := GetOrmer().QueryTable(&models.User{}).
|
||||
Filter("deleted", 0).
|
||||
Filter("user_id__gt", 1)
|
||||
|
||||
if query == nil {
|
||||
return qs
|
||||
|
@ -272,6 +272,11 @@ func (ua *UserAPI) Delete() {
|
||||
ua.CustomAbort(http.StatusForbidden, "can not delete yourself")
|
||||
}
|
||||
|
||||
if ua.userID == 1 {
|
||||
ua.HandleForbidden(ua.SecurityCtx.GetUsername())
|
||||
return
|
||||
}
|
||||
|
||||
var err error
|
||||
err = dao.DeleteUser(ua.userID)
|
||||
if err != nil {
|
||||
|
@ -68,8 +68,8 @@ func initRouters() {
|
||||
beego.Router("/api/projects/:id([0-9]+)/publicity", &api.ProjectAPI{}, "put:ToggleProjectPublic")
|
||||
beego.Router("/api/projects/:id([0-9]+)/logs", &api.ProjectAPI{}, "get:Logs")
|
||||
beego.Router("/api/statistics", &api.StatisticAPI{})
|
||||
beego.Router("/api/users/:id", &api.UserAPI{}, "get:Get")
|
||||
beego.Router("/api/users", &api.UserAPI{}, "get:List;post:Post;delete:Delete;put:Put")
|
||||
beego.Router("/api/users/:id", &api.UserAPI{}, "get:Get;delete:Delete;put:Put")
|
||||
beego.Router("/api/users", &api.UserAPI{}, "get:List;post:Post")
|
||||
beego.Router("/api/users/:id([0-9]+)/password", &api.UserAPI{}, "put:ChangePassword")
|
||||
beego.Router("/api/internal/syncregistry", &api.InternalAPI{}, "post:SyncRegistry")
|
||||
beego.Router("/api/repositories", &api.RepositoryAPI{}, "get:Get")
|
||||
|
Loading…
Reference in New Issue
Block a user