michael / editable-website

A SvelteKit template for building CMS-free editable websites
https://editable.website
MIT License
1.52k stars 121 forks source link

Improve error message on save when not authorized #19

Closed FarisMarouane closed 1 year ago

FarisMarouane commented 1 year ago

Hello and thank you for open sourcing your project. It's really an awesome idea !

I keep however getting the following sqlite (?) error whenever I try to save an edit:

Server side:

SELECT session_id, expires FROM sessions WHERE session_id = NULL AND expires > '2023-07-02T19:06:35.601Z' Error: Not authorized at Module.createOrUpdatePage (/home/marouane/webDev/site-editable/src/lib/api.js:255:27) at POST (/home/marouane/webDev/site-editable/src/routes/api/save-page/+server.js:11:31) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Module.render_endpoint (/home/marouane/webDev/site-editable/node_modules/@sveltejs/kit/src/runtime/server/endpoint.js:47:18) at async resolve (/home/marouane/webDev/site-editable/node_modules/@sveltejs/kit/src/runtime/server/respond.js:403:17) at async Object.handle (/home/marouane/webDev/site-editable/src/hooks.server.js:8:20) at async Module.respond (/home/marouane/webDev/site-editable/node_modules/@sveltejs/kit/src/runtime/server/respond.js:274:20) at async file:///home/marouane/webDev/site-editable/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:505:22

Client side

A 500 error response on the path /api/save-page.

I face the same 500 error on https://editable.website/ whenever I try to save an edit.

I use chrome on an ubuntu if this can help.

michael commented 1 year ago

Thank you, I need to improve the error message in the demo, but the behavior is expected. Without being authorized (signed in as an admin) you can't save change to a page.

To authorize (e.g. on your local installation) navigate to /login and enter the ADMIN_PASSWORD set in .env.

FarisMarouane commented 1 year ago

Thank you for your quick reply :)

michael commented 1 year ago

Should be fixed.