feat: add Twitter authentication provider and update sign-in callback to include it
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import NextAuth from "next-auth";
|
||||
import Google from "next-auth/providers/google";
|
||||
import Facebook from "next-auth/providers/facebook";
|
||||
import Twitter from "next-auth/providers/twitter";
|
||||
import Credentials from "next-auth/providers/credentials";
|
||||
|
||||
export const { handlers, signIn, signOut, auth } = NextAuth({
|
||||
@@ -17,6 +18,12 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
|
||||
clientSecret: process.env.FACEBOOK_CLIENT_SECRET!,
|
||||
}),
|
||||
|
||||
// Twitter OAuth
|
||||
Twitter({
|
||||
clientId: process.env.TWITTER_CLIENT_ID!,
|
||||
clientSecret: process.env.TWITTER_CLIENT_SECRET!,
|
||||
}),
|
||||
|
||||
// Email/Password (Credentials)
|
||||
Credentials({
|
||||
name: "credentials",
|
||||
@@ -64,7 +71,7 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
|
||||
callbacks: {
|
||||
async signIn({ user, account }) {
|
||||
// For OAuth providers, sync with backend
|
||||
if (account?.provider === "google" || account?.provider === "facebook") {
|
||||
if (account?.provider === "google" || account?.provider === "facebook" || account?.provider === "twitter") {
|
||||
try {
|
||||
const res = await fetch(
|
||||
`${process.env.NEXT_PUBLIC_API_URL}/auth/social`,
|
||||
|
||||
Reference in New Issue
Block a user