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 NextAuth from "next-auth";
|
||||||
import Google from "next-auth/providers/google";
|
import Google from "next-auth/providers/google";
|
||||||
import Facebook from "next-auth/providers/facebook";
|
import Facebook from "next-auth/providers/facebook";
|
||||||
|
import Twitter from "next-auth/providers/twitter";
|
||||||
import Credentials from "next-auth/providers/credentials";
|
import Credentials from "next-auth/providers/credentials";
|
||||||
|
|
||||||
export const { handlers, signIn, signOut, auth } = NextAuth({
|
export const { handlers, signIn, signOut, auth } = NextAuth({
|
||||||
@@ -17,6 +18,12 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
|
|||||||
clientSecret: process.env.FACEBOOK_CLIENT_SECRET!,
|
clientSecret: process.env.FACEBOOK_CLIENT_SECRET!,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
// Twitter OAuth
|
||||||
|
Twitter({
|
||||||
|
clientId: process.env.TWITTER_CLIENT_ID!,
|
||||||
|
clientSecret: process.env.TWITTER_CLIENT_SECRET!,
|
||||||
|
}),
|
||||||
|
|
||||||
// Email/Password (Credentials)
|
// Email/Password (Credentials)
|
||||||
Credentials({
|
Credentials({
|
||||||
name: "credentials",
|
name: "credentials",
|
||||||
@@ -64,7 +71,7 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
|
|||||||
callbacks: {
|
callbacks: {
|
||||||
async signIn({ user, account }) {
|
async signIn({ user, account }) {
|
||||||
// For OAuth providers, sync with backend
|
// For OAuth providers, sync with backend
|
||||||
if (account?.provider === "google" || account?.provider === "facebook") {
|
if (account?.provider === "google" || account?.provider === "facebook" || account?.provider === "twitter") {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`${process.env.NEXT_PUBLIC_API_URL}/auth/social`,
|
`${process.env.NEXT_PUBLIC_API_URL}/auth/social`,
|
||||||
|
|||||||
Reference in New Issue
Block a user