diff --git a/backend/src/app/rpc/mutations/teams.clj b/backend/src/app/rpc/mutations/teams.clj index 4245f1935..82fb7a7f4 100644 --- a/backend/src/app/rpc/mutations/teams.clj +++ b/backend/src/app/rpc/mutations/teams.clj @@ -103,7 +103,7 @@ (let [perms (teams/check-read-permissions! conn profile-id id) members (teams/retrieve-team-members conn id)] - (when (:is-owner perms) + (when (some :is-owner perms) (ex/raise :type :validation :code :owner-cant-leave-team :hint "reasing owner before leave")) @@ -129,7 +129,7 @@ [{:keys [pool] :as cfg} {:keys [id profile-id] :as params}] (db/with-atomic [conn pool] (let [perms (teams/check-edition-permissions! conn profile-id id)] - (when-not (:is-owner perms) + (when-not (some :is-owner perms) (ex/raise :type :validation :code :only-owner-can-delete-team)) @@ -298,7 +298,7 @@ :member-email (:email member email) :member-id (:id member)})] - (when-not (:is-admin perms) + (when-not (some :is-admin perms) (ex/raise :type :validation :code :insufficient-permissions)) diff --git a/backend/src/app/rpc/permissions.clj b/backend/src/app/rpc/permissions.clj index 9b4bae5b0..4566c550f 100644 --- a/backend/src/app/rpc/permissions.clj +++ b/backend/src/app/rpc/permissions.clj @@ -19,13 +19,14 @@ (us/assert fn? qfn) (fn [& args] (let [rows (apply qfn args)] - (when (or (empty? rows) - (not (or (some :can-edit rows) - (some :is-admin rows) - (some :is-owner rows)))) + (if (or (empty? rows) + (not (or (some :can-edit rows) + (some :is-admin rows) + (some :is-owner rows)))) (ex/raise :type :not-found :code :object-not-found - :hint "not found"))))) + :hint "not found") + rows)))) (defn make-read-check-fn "A simple factory for read permission check functions." @@ -33,8 +34,7 @@ (us/assert fn? qfn) (fn [& args] (let [rows (apply qfn args)] - (when-not (seq rows) + (if-not (seq rows) (ex/raise :type :not-found - :code :object-not-found))))) - - + :code :object-not-found) + rows))))