Skip to content

Verify callback not returning user data #4

@DiegoGBrisa

Description

@DiegoGBrisa

Every time I try to login using the Google strategy I get the state param within the URL but the verify callback within the GoogleStrategy class won't run, so I am not able to return the user data


1. authenticator
2.   .use(
3.     new FormStrategy(async ({ form: formData }) => {
4.       return await login(formData)
5.     }),
6.     'standard'
7.   )
8.   .use(
9.     new GoogleStrategy(
10.       {
11.         clientID: GOOGLE_CLIENT_ID,
12.         clientSecret: GOOGLE_CLIENT_SECRET,
13.         callbackURL: GOOGLE_CALLBACK_URL
14.       },
15.       // Verify Function
16.       async ({ accessToken, profile }) => {
17.         const user = await db.user.findUnique({
18.           where: {
19.             email: profile.emails[0].value
20.           }
21.         })
22.         if (user) {
23.           return { user, token: accessToken }
24.         } else {
25.           const { givenName, middleName, familyName } = profile.name
26.           const newUser = await db.user.create({
27.             data: {
28.               name: `${givenName} ${middleName} ${familyName}`,
29.               user_name: profile.displayName,
30.               email: profile.emails[0].value,
31.               password: accessToken,
32.               profile_img: profile.photos[0].value
33.             }
34.           })
35.           return { user: newUser, token: accessToken }
36.         }
37.       }
38.     ),
39.     'google'
40.   )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions