mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 23:21:08 +02:00
1.6 KiB
1.6 KiB
Authentication Fix Summary
Problem
Login and registration were failing with these errors:
- Login: "⚠️ Invalid email or password"
- Registration: "⚠️ Registration failed. Please check your information and try again."
Root Cause
PocketBase requires an id field when creating new user records. The code was not providing this required field, causing registration to fail with a validation error.
Solution Applied
1. Fixed Registration Code
Updated /src/routes/register/+page.server.ts to generate a random ID:
const randomId = Math.random().toString(36).substring(2, 17);
const userData: any = {
id: randomId, // Added this line
email,
password,
passwordConfirm,
emailVisibility: true
};
2. Test User Created
Created a test user for development:
- Email:
test@example.com - Password:
test123456
Testing the Fix
Login
- Go to http://localhost:5179/login
- Use credentials:
- Email: test@example.com
- Password: test123456
Registration
- Go to http://localhost:5179/register
- Register with any new email
- The registration should now work correctly
Additional Notes
- The PocketBase instance is running at: https://pb.ulo.ad
- The users collection requires the
idfield to be provided during creation - After registration, users are redirected to login page
- Users need to set their username after first login at
/setup-username
Debug Scripts Created
debug-auth.mjs- Tests authentication and registrationsetup-test-user.mjs- Creates a test user account
Run these with: node [script-name]