blefnk / relivator-nextjs-saas-ecommerce-starter

✨ 1.3.0 RC — Coming soon ⭐ Next.js 15 eCommerce Template ▲ i18n Stripe Shadcn Tailwind Drizzle Zod tRPC TypeScript Clerk Radix UI, Responsive React 18 19 Server Components, Postgres Neon TS ORM, Intl App Router Docs User Actions Kit, SaaS Commerce eCommerce Shop Pricing Payments Dark Mode Full Stack Free ⭐ more stars 👉 more features
https://relivator.com/en-US
MIT License
1.08k stars 216 forks source link

Fix wrong authentication #11

Closed blefnk closed 1 year ago

blefnk commented 1 year ago

The app currently has a limitation where it treats all logged-in users as if they were the first user who registered. This means that even if you log in with different providers or create another one user, the system still recognizes everyone as that first user.

Because of this, only the first user can link their social accounts, blocking other users from doing the same.

I suspect this issue might be related to the Cuid2() function used for automatic string generation for user's id in the Drizzle schema file src/data/db/schema.ts. Previously, auto-increment was used, using prime numbers with a serial() function.

I'm actively working to resolve this problem and would appreciate any contributions, whether it's through Pull Requests or by conducting research and testing to help diagnose the issue.

blefnk commented 1 year ago

Thanks to the Drizzle NextAuth.js adapter, accounts linking is now works automatically. If you use the same email for authentication as before, NextAuth.js will handle everything on its own.

So, I rewrote the system from my own multi-account implementation to a more classical one, and everything now works as it should. This issue is resolved.

But if anyone has an idea to improve my custom multi-account implementation, just check 1.0.0 commit and create a Pull Request and I will definitely consider it.

I will commit the new version of Relivator soon and close this issue; everything now works well.

blefnk commented 1 year ago

Relivator v1.1.0 has been released! 🎊 It now offers an improved user authentication process, with the ability to switch technologies on-the-fly, such as NextAuth.js/Clerk and PostgreSQL/MySQL! Even more improvements are on the way!