Skip to content

Commit

Permalink
chore: Remove unnecessary console.log statements and update user crea…
Browse files Browse the repository at this point in the history
…tion in auth.server.ts and userService.ts
  • Loading branch information
ttizze committed Jul 14, 2024
1 parent 206de62 commit c96e8ac
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
5 changes: 0 additions & 5 deletions web/app/utils/auth.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,20 @@ 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)
try {
const newUser = await prisma.user.create({
data: {
email: profile.emails[0].value || '',
password: '',
name: profile.displayName,
provider: 'google',
},
})
console.log('New user created:', newUser)
return newUser
} catch (error) {
console.error('Error creating new user:', error)
Expand Down
2 changes: 1 addition & 1 deletion web/app/utils/userService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export async function getOrCreateAIUser(name: string): Promise<number> {
const user = await prisma.user.upsert({
where: { email: `${name}@ai.com` },
update: {},
create: { name, email: `${name}@ai.com`, isAI: true, password: '' },
create: { name, email: `${name}@ai.com`, isAI: true},
});

return user.id;
Expand Down
2 changes: 2 additions & 0 deletions web/prisma/migrations/20240714082446_/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "users" ALTER COLUMN "password" DROP NOT NULL;
2 changes: 1 addition & 1 deletion web/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ datasource db {
model User {
id Int @id @default(autoincrement())
email String @unique
password String
password String?
name String
plan String @default("free")
totalPoints Int @default(0) @map("total_points")
Expand Down

0 comments on commit c96e8ac

Please sign in to comment.