authenticate with external/social providers

default discord avatar
lorentzo92
last month
2

Hi Everyone, i am studying payload and i would like to propose it to my clients, we are a software house based in Milan, Italy. One thing that is not super clear to me is how to handle auth users calling the cms apis from my nextjs frontend: suppose my client has a dedicated server for managing users and authentication, from nextjs users signup/login using email or social providers and then i have a nextauth session containing the user info. Now how do i combine this with the payload jwt token? I am thinking something like: when a user signup/login, i check if there exist a user with that email in the user collection, if so i (force) login (serverside) to payloadcms with that user and a fixed secret password so that i return the jwt token to pass in future apis against the cms. If the user does not exist then i create a new doc in my user collection and then login. What do you think? Do you have better approaches? Or maybe i am missing something… thanks 🙂

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.