From 69ab85a2bc2ca0ba22242d4d0e9d33bd695a2edb Mon Sep 17 00:00:00 2001 From: kshitij katiyar <90389917+Kshitij-Katiyar@users.noreply.github.com> Date: Fri, 17 May 2024 19:47:55 +0530 Subject: [PATCH] [MM-493]: Fixed the bug 'don't have the permissions to create subscriptions for this project (#495) * [MM-493]: Fixed the bug 'don't have the permissions to create subscriptions for this project' * [MM-493]: Fixed lint errors * [MM-493]: Fixed review comments * [MM-493]: Fixed CI --- server/webhook.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/webhook.go b/server/webhook.go index 9994e82f..9241335f 100644 --- a/server/webhook.go +++ b/server/webhook.go @@ -230,8 +230,11 @@ func (p *Plugin) permissionToProject(ctx context.Context, userID, namespace, pro return false } - // Check for guest level permissions - if result.Permissions.ProjectAccess == nil || result.Permissions.ProjectAccess.AccessLevel == gitlabLib.GuestPermissions { + // User permission for the project + userPermission := result.Permissions + + // Check if the user has guest permission or less for both project and group level + if (userPermission.ProjectAccess != nil && userPermission.ProjectAccess.AccessLevel <= gitlabLib.GuestPermissions) || (userPermission.GroupAccess != nil && userPermission.GroupAccess.AccessLevel <= gitlabLib.GuestPermissions) { return false }