blefnk / relivator-nextjs-template

1.2.6 is coming on July 3 💜 Next.js 15 Store-Landing-Dashboard Starter ▲ i18n Stripe Shadcn Tailwind Drizzle Zod tRPC TypeScript Clerk Authjs Radix UI, Responsive React 19 Server Components, MySQL Postgres Neon TS ORM, Intl App Router Docs User Actions Kit, SaaS Commerce Shop Pricing Payments, Dark Mode, Full Stack Free ▲ more stars → more feature
https://github.com/blefnk/relivator/issues/38#issuecomment-2183480924
MIT License
849 stars 188 forks source link

Fix wrong authentication #11

Closed blefnk closed 8 months ago

blefnk commented 9 months 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 9 months 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 8 months 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!