-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4992b60
commit a00cb4a
Showing
37 changed files
with
89 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,5 @@ | ||
import { prisma } from "@/lib/prisma" | ||
import { updateFirstNameById } from "@/lib/users/updateFirstNameById" | ||
import { PrismaAdapter } from "@next-auth/prisma-adapter" | ||
import NextAuth, { AuthOptions, Session, User } from "next-auth" | ||
import GoogleProvider from "next-auth/providers/google" | ||
import EmailProvider from "next-auth/providers/email" | ||
import { sendVerificationRequest } from "@/utils/send-verification-request" | ||
import { trackIssue } from "@/lib/trackIssue" | ||
|
||
export const authOptions: AuthOptions = { | ||
adapter: PrismaAdapter(prisma), | ||
providers: [ | ||
GoogleProvider({ | ||
clientId: process.env.GOOGLE_CLIENT_ID!, | ||
clientSecret: process.env.GOOGLE_CLIENT_SECRET!, | ||
profile: (profile) => ({ | ||
id: profile.sub, | ||
name: profile.name, | ||
firstName: profile.given_name, | ||
email: profile.email, | ||
emailVerified: profile.email_verified, | ||
image: profile.picture, | ||
}), | ||
}), | ||
EmailProvider({ | ||
server: "", | ||
from: "Wishlist <[email protected]>", | ||
sendVerificationRequest, | ||
}), | ||
], | ||
callbacks: { | ||
session: ({ session, user }: { session: Session; user: User }) => { | ||
session.user.id = user.id | ||
session.user.firstName = user.firstName | ||
session.user.isAdmin = user.id === process.env.ADMIN_USER_ID | ||
|
||
return session | ||
}, | ||
}, | ||
events: { | ||
signIn: async ({ profile, user, isNewUser }) => { | ||
trackIssue("User sign in", "info", { ...user, isNewUser }) | ||
|
||
if (!isNewUser && !user.firstName && profile?.firstName) { | ||
await updateFirstNameById(user.id, profile.firstName) | ||
} | ||
}, | ||
signOut: ({ session }) => { | ||
trackIssue("User sign out", "info", session.user) | ||
}, | ||
}, | ||
} | ||
import { authOptions } from "@/lib/nextAuth" | ||
import NextAuth from "next-auth" | ||
|
||
const handler = NextAuth(authOptions) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { prisma } from "@/lib/prisma" | ||
import { updateFirstNameById } from "@/lib/users/updateFirstNameById" | ||
import { PrismaAdapter } from "@next-auth/prisma-adapter" | ||
import { AuthOptions, Session, User } from "next-auth" | ||
import GoogleProvider from "next-auth/providers/google" | ||
import EmailProvider from "next-auth/providers/email" | ||
import { sendVerificationRequest } from "@/utils/send-verification-request" | ||
import { trackIssue } from "@/lib/trackIssue" | ||
|
||
export const authOptions: AuthOptions = { | ||
adapter: PrismaAdapter(prisma), | ||
providers: [ | ||
GoogleProvider({ | ||
clientId: process.env.GOOGLE_CLIENT_ID!, | ||
clientSecret: process.env.GOOGLE_CLIENT_SECRET!, | ||
profile: (profile) => ({ | ||
id: profile.sub, | ||
name: profile.name, | ||
firstName: profile.given_name, | ||
email: profile.email, | ||
emailVerified: profile.email_verified, | ||
image: profile.picture, | ||
}), | ||
}), | ||
EmailProvider({ | ||
server: "", | ||
from: "Wishlist <[email protected]>", | ||
sendVerificationRequest, | ||
}), | ||
], | ||
callbacks: { | ||
session: ({ session, user }: { session: Session; user: User }) => { | ||
session.user.id = user.id | ||
session.user.firstName = user.firstName | ||
session.user.isAdmin = user.id === process.env.ADMIN_USER_ID | ||
|
||
return session | ||
}, | ||
}, | ||
events: { | ||
signIn: async ({ profile, user, isNewUser }) => { | ||
trackIssue("User sign in", "info", { ...user, isNewUser }) | ||
|
||
if (!isNewUser && !user.firstName && profile?.firstName) { | ||
await updateFirstNameById(user.id, profile.firstName) | ||
} | ||
}, | ||
signOut: ({ session }) => { | ||
trackIssue("User sign out", "info", session.user) | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.