From 0913a85f2a4d234366b9b229fe20511b107460fe Mon Sep 17 00:00:00 2001 From: zhzhang Date: Tue, 10 Dec 2024 19:12:52 +0800 Subject: [PATCH] Fix repo permission check bug --- component/repo.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/component/repo.go b/component/repo.go index 7a18fa68..95a73d01 100644 --- a/component/repo.go +++ b/component/repo.go @@ -1429,13 +1429,10 @@ func (c *repoComponentImpl) AllowReadAccess(ctx context.Context, repoType types. } func (c *repoComponentImpl) AllowWriteAccess(ctx context.Context, repoType types.RepositoryType, namespace, name, username string) (bool, error) { - repo, err := c.repoStore.FindByPath(ctx, repoType, namespace, name) + _, err := c.repoStore.FindByPath(ctx, repoType, namespace, name) if err != nil { return false, fmt.Errorf("failed to find repo, error: %w", err) } - if !repo.Private { - return true, nil - } if username == "" { return false, ErrUserNotFound @@ -1445,13 +1442,10 @@ func (c *repoComponentImpl) AllowWriteAccess(ctx context.Context, repoType types } func (c *repoComponentImpl) AllowAdminAccess(ctx context.Context, repoType types.RepositoryType, namespace, name, username string) (bool, error) { - repo, err := c.repoStore.FindByPath(ctx, repoType, namespace, name) + _, err := c.repoStore.FindByPath(ctx, repoType, namespace, name) if err != nil { return false, fmt.Errorf("failed to find repo, error: %w", err) } - if !repo.Private { - return true, nil - } if username == "" { return false, ErrUserNotFound