Next.js Discord

Discord Forum

Send additional parameters on SignIn() with GoogleProvider

Unanswered
Giant panda posted this in #help-forum
Open in Discord
Giant pandaOP
I have a special use case for my login.

Quick run down:

I have 2 login forms for Users/Admins which are on the same page
The auth logic for these 2 roles is different
I want credentials and Google login
Because of the fact that i have 2 forms and 2 roles, I want to send the user's role (depending on which form the user sent) together with the SignIn() request.
With credentials provider I can do something like this:

signIn("credentials", { redirect: false, password: "password", email: "email@gmail.com", userType: "coach", });
and all these properties appear in the authorize callback inside CredentialsProvider. ✔

But now I want to do the same thing with GoogleProvider. In the docs I found only signIn("google"), but i tried it like credentials just to see. Which looks something like this:

signIn("google", { userType: "user" });

Now how can i get them backin the belo area
GoogleProvider( { id: "google", name: "google", profile(profile) { console.log(profile); return { ...profile, id: profile.sub, role: "google", }; }, clientId: process.env.NEXT_PUBLIC_GOOGLE_ID, clientSecret: process.env.NEXT_PUBLIC_GOOGLE_SECRET, })

0 Replies