adrien2p / medusa-plugins

A collection of awesome plugins for medusa :rocket:
https://medusa-plugins.vercel.app
MIT License
161 stars 46 forks source link

Cannot register if order is made as guest #93

Closed FaZeRs closed 1 year ago

FaZeRs commented 1 year ago

medusa-plugin-auth I'm receiving Internal Server Error if I'm trying to register after I have made an order without registration


Error: Guest customer with email already exists
at CustomerService.<anonymous> (/app/node_modules/@medusajs/medusa/dist/services/customer.js:419:55)
at step (/app/node_modules/@medusajs/medusa/dist/services/customer.js:59:23)
at Object.next (/app/node_modules/@medusajs/medusa/dist/services/customer.js:40:53)
at fulfilled (/app/node_modules/@medusajs/medusa/dist/services/customer.js:31:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
```
adrien2p commented 1 year ago

The current behaviour is that if no validated account exists then we try to create the customer, maybe we can change that to just check if any accounts exists with the email?

FaZeRs commented 1 year ago

I think this error is because password field is missing. When I try to register using signup form it works. If you call CustomerService.create method error will be the same.

https://github.com/medusajs/medusa/blob/develop/packages/medusa/src/services/customer.ts#L328

adrien2p commented 1 year ago

Yes and because a guest account already exists for this email

adrien2p commented 1 year ago

I will be 3 weeks away and tried to relax a bot, maybe if you could ipen a pr if you feel something can be done as a proposal so i can look at it when i am free, would you be keen to do that @FaZeRs ? 😍

FaZeRs commented 1 year ago

@adrien2p as I see alternative would be to create method in auth plugin which does the input data validation and creates customer using CustomerRepository. Maybe you have got any other ideas?

adrien2p commented 1 year ago

Did you find a solution for your case?