This commit is contained in:
eric
2025-11-13 05:05:53 +08:00
parent cbdc65f56e
commit 891af61146
691 changed files with 83952 additions and 0 deletions

View 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

View 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
}
}
}

View File

@@ -0,0 +1,4 @@
import { GET, POST } from '@/lib/auth'
export const runtime = 'edge'
export { GET, POST }