's'
This commit is contained in:
20
app/api/auth/[...nextauth]/auth.ts
Normal file
20
app/api/auth/[...nextauth]/auth.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import type { NextAuthConfig } from 'next-auth'
|
||||
import GithubProvider from 'next-auth/providers/github'
|
||||
|
||||
export const authConfig: NextAuthConfig = {
|
||||
providers: [
|
||||
GithubProvider({
|
||||
clientId: process.env.GITHUB_CLIENT_ID!,
|
||||
clientSecret: process.env.GITHUB_SECRET!,
|
||||
authorization: {
|
||||
params: { scope: 'repo' }
|
||||
}
|
||||
})
|
||||
],
|
||||
secret: process.env.NEXTAUTH_SECRET,
|
||||
session: {
|
||||
strategy: 'jwt'
|
||||
}
|
||||
}
|
||||
|
||||
export default authConfig
|
||||
37
app/api/auth/[...nextauth]/config.ts
Normal file
37
app/api/auth/[...nextauth]/config.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import type { NextAuthConfig } from 'next-auth'
|
||||
import GitHub from 'next-auth/providers/github'
|
||||
import type { DefaultSession, JWT } from 'next-auth'
|
||||
|
||||
declare module 'next-auth' {
|
||||
interface Session {
|
||||
user: {
|
||||
accessToken?: string
|
||||
} & DefaultSession['user']
|
||||
}
|
||||
}
|
||||
|
||||
export const authConfig: NextAuthConfig = {
|
||||
providers: [
|
||||
GitHub({
|
||||
clientId: process.env.GITHUB_CLIENT_ID!,
|
||||
clientSecret: process.env.GITHUB_SECRET!,
|
||||
authorization: {
|
||||
params: { scope: 'repo' }
|
||||
}
|
||||
})
|
||||
],
|
||||
callbacks: {
|
||||
async jwt({ token, account }) {
|
||||
if (account?.access_token) {
|
||||
token.accessToken = account.access_token
|
||||
}
|
||||
return token
|
||||
},
|
||||
async session({ session, token }) {
|
||||
if (session?.user) {
|
||||
session.user.accessToken = token.accessToken as string
|
||||
}
|
||||
return session
|
||||
}
|
||||
}
|
||||
}
|
||||
4
app/api/auth/[...nextauth]/route.ts
Normal file
4
app/api/auth/[...nextauth]/route.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { GET, POST } from '@/lib/auth'
|
||||
|
||||
export const runtime = 'edge'
|
||||
export { GET, POST }
|
||||
Reference in New Issue
Block a user