Open ABAGDevelopment opened 2 days ago
@ABAGDevelopment, any chance you can provide the exact steps to reproduce the error?
The error you are seeing on the first attempt to accept an invite is thrown in case the HTTP request already carries authentication, potentially from a separate, earlier session. I'd like to understand how you managed to reach this state, as it should generally not be possible in Medusa Admin.
@olivermrbl : - Below are the steps. • Invite a user and enter email address • Copy the invite link open in the browser and enter details and click create account, " UI Message the invite is invalid or expired", Api response in mentioned in the description above
@ABAGDevelopment, can I get you to ensure you are signed out of the dashboard with your other user (the one that invited the new user)? Otherwise, the authentication context from that session will be part of the HTTP request to accept the token.
Package.json file
Node.js version
v21
Database and its version
Postgres 16.2
Operating system name and version
Windows 11
Browser name
Chrome
What happended?
Admin User invite and login functionality not working and causing errors
Below is the traceCreating a new user : - Below are the steps
• Invite a user and enter email address • Copy the invite link open in the browser and enter details and click create account, below message appears
Below is the response from medusa API
http: POST /auth/user/emailpass/register ← http://localhost:9000/app/invite?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6Imludml0ZV8wMUpEUk1XM0sxQkJYRks5QlY0TThOWjBSNSIsImVtYWlsIjoiYWRtaW5AeW9wbWFpbC5jb20iLCJpYXQiOjE3MzI3NzI3NjEsImV4cCI6MTgxOTE3Mjc2MSwianRpIjoiZjUxMjZhMWItNGJlZS00ZTNlLWI2NjQtZGIwZGNlNWI2ZTIxIn0.yrq-qWHwZ1Etwp6UusBNGuJwYuUTLKhBSZCWYvxKpVY (200) - 103.347 ms error: The user is already authenticated and cannot accept an invite. MedusaError: The user is already authenticated and cannot accept an invite. at POST (C:\Projects\Medusa\basicsetup\my-medusa-store\node_modules\@medusajs\medusa\src\api\admin\invites\accept\route.ts:15:11) at C:\Projects\Medusa\basicsetup\my-medusa-store\node_modules\@medusajs\utils\src\common\wrap-handler.ts:17:20 at Layer.handle [as handle_request] (C:\Projects\Medusa\basicsetup\my-medusa-store\node_modules\express\lib\router\layer.js:95:5) at next (C:\Projects\Medusa\basicsetup\my-medusa-store\node_modules\express\lib\router\route.js:149:13) at Route.dispatch (C:\Projects\Medusa\basicsetup\my-medusa-store\node_modules\express\lib\router\route.js:119:3) at Layer.handle [as handle_request] (C:\Projects\Medusa\basicsetup\my-medusa-store\node_modules\express\lib\router\layer.js:95:5) at C:\Projects\Medusa\basicsetup\my-medusa-store\node_modules\express\lib\router\index.js:284:15 at Function.process_params (C:\Projects\Medusa\basicsetup\my-medusa-store\node_modules\express\lib\router\index.js:346:12) at next (C:\Projects\Medusa\basicsetup\my-medusa-store\node_modules\express\lib\router\index.js:280:10) at next (C:\Projects\Medusa\basicsetup\my-medusa-store\node_modules\express\lib\router\route.js:141:14) { __isMedusaError: true, type: 'invalid_data', code: undefined, date: 2024-11-28T06:01:52.872Z }
The user is already authenticated and cannot accept an invite. : - User table does not have any entry for the mentioned user
So above message returned from the API is misleading
Attempt 2 with the invite link
http: GET /app/index.css ← http://localhost:9000/app/entry.tsx (200) - 2.296 ms error: Identity with email already exists MedusaError: Identity with email already exists at POST (C:\Projects\Medusa\basicsetup\my-medusa-store\node_modules\@medusajs\medusa\src\api\auth[actor_type][auth_provider]\register\route.ts:52:9) at processTicksAndRejections (node:internal/process/task_queues:95:5) at async C:\Projects\Medusa\basicsetup\my-medusa-store\node_modules\@medusajs\utils\src\common\wrap-handler.ts:17:14 { __isMedusaError: true, type: 'unauthorized', code: undefined, date: 2024-11-28T06:13:24.488Z }
New entry in auth_identity table with app_metadata as null
Now regardless of number of attempts to create admin user, Application will keep throwing Server Error.
Expected behavior
User Should be able to seemlessly login
Actual behavior
Admin User invite and login functionality not working and causing errors
Link to reproduction repo
https://github.com/medusajs/medusa