Remove auth
This commit is contained in:
@@ -1,82 +0,0 @@
|
||||
import NextAuth from "next-auth"
|
||||
import Credentials from "next-auth/providers/credentials"
|
||||
import Twitter from "next-auth/providers/twitter"
|
||||
import Google from "next-auth/providers/google"
|
||||
import GitHub from "next-auth/providers/github"
|
||||
import axios from "axios"
|
||||
|
||||
export const { handlers, auth } = NextAuth({
|
||||
providers: [
|
||||
Credentials({
|
||||
credentials: {
|
||||
username: {},
|
||||
password: {}
|
||||
},
|
||||
async authorize(credentials) {
|
||||
try {
|
||||
const user = await axios.post(
|
||||
`${process.env.NEXT_PUBLIC_API_URL}/auth/local`,
|
||||
{
|
||||
identifier: credentials.username,
|
||||
password: credentials.password
|
||||
}
|
||||
)
|
||||
|
||||
return user.data || null
|
||||
} catch (error) {
|
||||
throw new Error(error.response?.data?.error?.message)
|
||||
}
|
||||
}
|
||||
}),
|
||||
Twitter({
|
||||
clientId: process.env.NEXT_PUBLIC_TWITTER_API_KEY,
|
||||
clientSecret: process.env.NEXT_PUBLIC_TWITTER_API_KEY_SECRET
|
||||
}),
|
||||
Google({
|
||||
clientId: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID,
|
||||
clientSecret: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_SECRET
|
||||
}),
|
||||
GitHub({
|
||||
clientId: process.env.NEXT_PUBLIC_GITHUB_CLIENT_ID,
|
||||
clientSecret: process.env.NEXT_PUBLIC_GITHUB_CLIENT_SECRET
|
||||
})
|
||||
],
|
||||
session: {
|
||||
strategy: "jwt",
|
||||
trustHost: true
|
||||
},
|
||||
secret: process.env.NEXT_PUBLIC_JWT_SECRET,
|
||||
callbacks: {
|
||||
async jwt({ token, user, account }) {
|
||||
if (user && account) {
|
||||
let url = `${process.env.NEXT_PUBLIC_API_URL}/auth/${account.provider}/callback`
|
||||
|
||||
if (account.provider === "twitter") {
|
||||
url += `?access_token=${account.oauth_token}&access_secret=${account.oauth_token_secret}`
|
||||
} else {
|
||||
url += `?access_token=${account.access_token}`
|
||||
}
|
||||
|
||||
const response = await fetch(url)
|
||||
const data = await response.json()
|
||||
|
||||
token.id = data.id || user.id
|
||||
token.jwt = data.jwt || user.jwt
|
||||
token.user = data.user || user.user
|
||||
}
|
||||
|
||||
return token
|
||||
},
|
||||
async session({ session, token }) {
|
||||
session.jwt = token.jwt
|
||||
session.user = token.user
|
||||
return session
|
||||
}
|
||||
},
|
||||
pages: {
|
||||
signIn: "/pwopose",
|
||||
error: "/pwopose"
|
||||
}
|
||||
})
|
||||
|
||||
export const { GET, POST } = handlers
|
||||
@@ -1,6 +1,5 @@
|
||||
import TopLoader from '../components/top-loader'
|
||||
import Navigasyon from '../components/navigasyon'
|
||||
import AuthProvider from './auth-provider'
|
||||
import ThemeRegistry from './theme-registy'
|
||||
|
||||
export const metadata = {
|
||||
@@ -56,12 +55,10 @@ export default async function RootLayout({children, Session}) {
|
||||
<html lang='fr' suppressHydrationWarning>
|
||||
<body>
|
||||
<TopLoader color='#ffeb3b' />
|
||||
<AuthProvider session={Session}>
|
||||
<ThemeRegistry>
|
||||
<Navigasyon />
|
||||
{children}
|
||||
</ThemeRegistry>
|
||||
</AuthProvider>
|
||||
<section>
|
||||
<script
|
||||
type='application/ld+json'
|
||||
|
||||
Reference in New Issue
Block a user