Hi everyone,
I’m working on a Next.js app and have successfully implemented email/password authentication, which is working fine. Recently, I added Google SSO to allow users to log in with their Gmail accounts, and that’s also functioning as expected.
However, I’ve run into an issue:
When an existing user who originally registered with email/password tries to log in using Google SSO with the same email, a new user account is created instead of linking to their existing account.
I’d like to enable users to access their account through any authentication method (email/password or Google SSO) without creating duplicate accounts.
Could anyone guide me on how to link users across different authentication providers? Are there best practices, libraries, or strategies I should follow?
Thanks in advance for your help!