Comment suggestions for auth.ts
This commit is contained in:
parent
bd4fc24e6f
commit
ced218b9dd
1 changed files with 3 additions and 4 deletions
7
auth.ts
7
auth.ts
|
|
@ -1,6 +1,5 @@
|
||||||
import NextAuth, { type DefaultSession } from 'next-auth'
|
import NextAuth, { type DefaultSession } from 'next-auth'
|
||||||
import GitHub from 'next-auth/providers/github'
|
import GitHub from 'next-auth/providers/github'
|
||||||
import { NextResponse } from 'next/server'
|
|
||||||
|
|
||||||
declare module 'next-auth' {
|
declare module 'next-auth' {
|
||||||
interface Session {
|
interface Session {
|
||||||
|
|
@ -14,7 +13,7 @@ declare module 'next-auth' {
|
||||||
export const {
|
export const {
|
||||||
handlers: { GET, POST },
|
handlers: { GET, POST },
|
||||||
auth,
|
auth,
|
||||||
CSRF_experimental
|
CSRF_experimental // will be removed in future
|
||||||
} = NextAuth({
|
} = NextAuth({
|
||||||
providers: [GitHub],
|
providers: [GitHub],
|
||||||
callbacks: {
|
callbacks: {
|
||||||
|
|
@ -26,10 +25,10 @@ export const {
|
||||||
return token
|
return token
|
||||||
},
|
},
|
||||||
authorized({ auth }) {
|
authorized({ auth }) {
|
||||||
return !!auth?.user
|
return !!auth?.user // this ensures there is a logged in user for -every- request
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pages: {
|
pages: {
|
||||||
signIn: '/sign-in'
|
signIn: '/sign-in' // overrides the next-auth default signin page https://authjs.dev/guides/basics/pages
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue