mirror of
https://github.com/goharbor/harbor
synced 2024-09-20 23:59:56 +00:00
Merge pull request #14428 from heww/fix-issue-14338
fix: search charts in the projects the user owned
This commit is contained in:
commit
cd15b4fbdb
|
@ -16,6 +16,7 @@ package api
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
|
@ -53,10 +54,6 @@ func (s *SearchAPI) Get() {
|
|||
query := q.New(q.KeyWords{})
|
||||
query.Sorting = "name"
|
||||
|
||||
if keyword != "" {
|
||||
query.Keywords["name"] = &q.FuzzyMatchValue{Value: keyword}
|
||||
}
|
||||
|
||||
if !s.SecurityCtx.IsSysAdmin() {
|
||||
if sc, ok := s.SecurityCtx.(*local.SecurityContext); ok && sc.IsAuthenticated() {
|
||||
user := sc.User()
|
||||
|
@ -82,6 +79,10 @@ func (s *SearchAPI) Get() {
|
|||
for _, p := range projects {
|
||||
proNames = append(proNames, p.Name)
|
||||
|
||||
if keyword != "" && !strings.Contains(p.Name, keyword) {
|
||||
continue
|
||||
}
|
||||
|
||||
if sc, ok := s.SecurityCtx.(*local.SecurityContext); ok && sc.IsAuthenticated() {
|
||||
roles, err := s.ProjectCtl.ListRoles(s.Context(), p.ProjectID, sc.User())
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user