apostrophecms / apostrophe-headless

Add REST APIs to your Apostrophe "pieces," powering your React/Vue/etc. apps with a headless CMS.
MIT License
98 stars 20 forks source link

Upload of attachments not working while logged in #49

Open RyamBaCo opened 4 years ago

RyamBaCo commented 4 years ago

On our Apostrophe website we implemented Vue components interacting with apostrophe pieces using apostrophe-headless. When i'm logged in in Apostrophe and try to upload files by POST against api/v1/attachments i receive "forbidden" as response string with 403 response. when i'm not logged in everything is working fine.

On further debugging it occurs that in api.js the self.apos.permissions-check for "edit-attachment" fails. The initial can-request to apostrophe-permissions returns true, but somehow one of the "can"-listeners sets info.response to false. I currently hack-fixed it by putting

  self.apos.on("can", async function (req, action, object, info) {
      if (action === "edit-attachment" && !info.response) {
        info.response = true;
      }
    });

in my code. But I guess that this shouldn't be the solution.

boutell commented 4 years ago

Hmm. Is workflow present?

On Fri, May 8, 2020 at 2:47 AM Ryam BaCo notifications@github.com wrote:

On our Apostrophe website we implemented Vue components interacting with apostrophe pieces using apostrophe-headless. When i'm logged in in Apostrophe and try to upload files by POST against api/v1/attachments i receive "forbidden" as response string with 403 response. when i'm not logged in everything is working fine.

On further debugging it occurs that in api.js the self.apos.permissions-check for "edit-attachment" fails. The initial can-request to apostrophe-permissions returns true, but somehow one of the "can"-listeners sets info.response to false. I currently hack-fixed it by putting

self.apos.on("can", async function (req, action, object, info) { if (action === "edit-attachment" && !info.response) { info.response = true; } });

in my code. But I guess that this shouldn't be the solution.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/apostrophecms/apostrophe-headless/issues/49, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAH27JW65NVDAQQGCXY4STRQOTGHANCNFSM4M354GEQ .

--

THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER APOSTROPHECMS | apostrophecms.com | he/him/his

boutell commented 4 years ago

The tests on this feature do pass, so I'd recommend contributing a failing test.

On Fri, May 8, 2020 at 11:55 AM Tom Boutell tom@apostrophecms.com wrote:

Hmm. Is workflow present?

On Fri, May 8, 2020 at 2:47 AM Ryam BaCo notifications@github.com wrote:

On our Apostrophe website we implemented Vue components interacting with apostrophe pieces using apostrophe-headless. When i'm logged in in Apostrophe and try to upload files by POST against api/v1/attachments i receive "forbidden" as response string with 403 response. when i'm not logged in everything is working fine.

On further debugging it occurs that in api.js the self.apos.permissions-check for "edit-attachment" fails. The initial can-request to apostrophe-permissions returns true, but somehow one of the "can"-listeners sets info.response to false. I currently hack-fixed it by putting

self.apos.on("can", async function (req, action, object, info) { if (action === "edit-attachment" && !info.response) { info.response = true; } });

in my code. But I guess that this shouldn't be the solution.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/apostrophecms/apostrophe-headless/issues/49, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAH27JW65NVDAQQGCXY4STRQOTGHANCNFSM4M354GEQ .

--

THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER APOSTROPHECMS | apostrophecms.com | he/him/his

--

THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER APOSTROPHECMS | apostrophecms.com | he/him/his