Skip to content

Commit

Permalink
fix/googleauath (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttizze authored Jul 14, 2024
1 parent 12842cd commit d6f3aee
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions web/app/utils/auth.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { FormStrategy } from 'remix-auth-form'
import { GoogleStrategy } from 'remix-auth-google'
import { prisma } from './prisma'
import { sessionStorage } from './session.server'
import { c } from 'node_modules/vite/dist/node/types.d-aGj9QkWt'

const SESSION_SECRET = process.env.SESSION_SECRET

Expand Down Expand Up @@ -60,12 +61,15 @@ const googleStrategy = new GoogleStrategy<User>(
callbackURL: `${process.env.CLIENT_URL}/api/auth/callback/google`,
},
async ({ profile }) => {
console.log('Profile:', profile)
const user = await prisma.user.findUnique({
where: { email: profile.emails[0].value },
})
if (user) {
console.log('User found:', user)
return user
}
console.log('User not found:', user)
const newUser = await prisma.user.create({
data: {
email: profile.emails[0].value || '',
Expand All @@ -74,6 +78,7 @@ const googleStrategy = new GoogleStrategy<User>(
provider: 'google',
},
})
console.log('New user created:', newUser)
return newUser
},
)
Expand Down

0 comments on commit d6f3aee

Please sign in to comment.