goniszewski/grimoire

ClientResponseError 400: Failed to authenticate.

Closed this issue · 4 comments

Describe the bug
Can't log in.

To Reproduce
Steps to reproduce the behavior:

  1. I cloned the repo
  2. ran docker-compose --env-file .env.docker up

Expected behavior
I could log in using the credentials in .env.docker

Screenshots
Additional context

Attaching to grimoire-pocketbase, grimoire
grimoire-pocketbase | 2023/11/29 20:52:18 Server started at http://0.0.0.0:80
grimoire-pocketbase | ├─ REST API: http://0.0.0.0:80/api/
grimoire-pocketbase | └─ Admin UI: http://0.0.0.0:80/_/
grimoire      | Listening on 0.0.0.0:5173
grimoire      | ClientResponseError 400: Failed to authenticate.
grimoire      |     at file:///app/node_modules/.pnpm/pocketbase@0.19.0/node_modules/pocketbase/dist/pocketbase.es.mjs:1:31144
grimoire      |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
grimoire      |     at async default (file:///app/build/server/chunks/7-cc1cc215.js:9:20)
grimoire      |     at async handle_action_request (file:///app/build/server/index.js:1072:18)
grimoire      |     at async render_page (file:///app/build/server/index.js:2508:23)
grimoire      |     at async resolve (file:///app/build/server/index.js:3524:24)
grimoire      |     at async Object.handle (file:///app/build/server/chunks/hooks.server-13110f1a.js:31:20)
grimoire      |     at async respond (file:///app/build/server/index.js:3410:22)
grimoire      |     at async Array.ssr (file:///app/build/handler.js:1221:3) {
grimoire      |   url: 'http://pocketbase/api/collections/users/auth-with-password',
grimoire      |   status: 400,
grimoire      |   response: { code: 400, message: 'Failed to authenticate.', data: {} },
grimoire      |   isAbort: false,
grimoire      |   originalError: {
grimoire      |     url: 'http://pocketbase/api/collections/users/auth-with-password',
grimoire      |     status: 400,
grimoire      |     data: { code: 400, message: 'Failed to authenticate.', data: {} }
grimoire      |   }
grimoire      | }
grimoire      | ClientResponseError 404: The requested resource wasn't found.
grimoire      |     at file:///app/node_modules/.pnpm/pocketbase@0.19.0/node_modules/pocketbase/dist/pocketbase.es.mjs:1:31144
grimoire      |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
grimoire      |     at async default (file:///app/build/server/chunks/12-e50058f8.js:14:7)
grimoire      |     at async handle_action_json_request (file:///app/build/server/index.js:997:18)
grimoire      |     at async resolve (file:///app/build/server/index.js:3524:24)
grimoire      |     at async Object.handle (file:///app/build/server/chunks/hooks.server-13110f1a.js:31:20)
grimoire      |     at async respond (file:///app/build/server/index.js:3410:22)
grimoire      |     at async Array.ssr (file:///app/build/handler.js:1221:3) {
grimoire      |   url: 'http://pocketbase/api/collections/categories/records',
grimoire      |   status: 404,
grimoire      |   response: {
grimoire      |     code: 404,
grimoire      |     message: "The requested resource wasn't found.",
grimoire      |     data: {}
grimoire      |   },
grimoire      |   isAbort: false,

@rtprio thank you for joining in!

The credentials you provided in .env.docker are meant for the initial admin user. It is mainly used to initiate the connection with PocketBase. In Grimoire users and admins are completely separate.

This being said, this is not a bug but an expected behavior. I know that the problem lies in the lack of documentation, and I will be working on this very shortly.

@rtprio please check again if the issue persists after pulling the latest changes. In addition, please keep in mind that some changes were made to how env file is handled: https://github.com/goniszewski/grimoire#steps

Ok, I saw some changes with .env, nice not to have to pass that to docker compose.

You say the admin credentials are for this pocketbase admin, ok. it says you can change them in pocketbase, fine. but there's no way to log in to pocketbase, and I also missed how to log in as an admin to grimoire. Or how to create an admin account in grimoire. Creating a mortal account in grimoire 500s. logging in is still a 401.

This is still very confusing. I'm not noticing anything different, other than the .env filename rename.

I have described the differences between Users and Admins here: https://grimoire.pro/docs/admins-vs-users

A root admin account is created from provided in .env credentials during first deployment as part of PocketBase initialization. You can create a new admin accounts from PB's admin panel.

As for the mentioned errors, I want to resolve this issue with this PR: #27