generated from dreampipcom/nexus
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ba2eb0
commit 889d4d5
Showing
5 changed files
with
102 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// config.ts | ||
export const authConfig = { | ||
providers, | ||
adapter: PrismaAdapter(PrivatePrisma), | ||
session: { | ||
strategy: 'jwt', | ||
}, | ||
events: {}, | ||
callbacks: { | ||
async signIn() { | ||
// extra sign-in checks | ||
return true; | ||
}, | ||
async redirect() { | ||
return `${process.env.MAIN_URL}`; | ||
}, | ||
async jwt({ user, token }) { | ||
if (user) { | ||
// Note that this if condition is needed | ||
token.user = { ...user }; | ||
} | ||
return token; | ||
}, | ||
async session({ session, token }) { | ||
if (token?.user) { | ||
// Note that this if condition is needed | ||
session.user = token.user; | ||
} | ||
return session; | ||
}, | ||
}, | ||
cookies: { | ||
pkceCodeVerifier: { | ||
name: 'next-auth.pkce.code_verifier', | ||
options: { | ||
httpOnly: true, | ||
sameSite: 'none', | ||
path: '/', | ||
secure: true, | ||
}, | ||
}, | ||
}, | ||
pages: { | ||
signIn: '/signin', | ||
signOut: '/', | ||
error: '/error', // Error code passed in query string as ?error= | ||
verifyRequest: '/verify', // (used for check email message) | ||
// newUser: '/' // New users will be directed here on first sign in (leave the property out if not of interest) | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// index.ts | ||
export { authOptions, auth, handlers } from './constants'; | ||
export { auth, handlers, authConfig } from './constants'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// middleware.ts | ||
import { authConfig } from '@auth'; | ||
import NextAuth from 'next-auth'; | ||
|
||
// Use only one of the two middleware options below | ||
// 1. Use middleware directly | ||
export const { auth: middleware } = NextAuth(authConfig); | ||
|
||
// 2. Wrapped middleware option | ||
// const { auth } = NextAuth(config) | ||
// export default auth(async function middleware(req: NextRequest) { | ||
// // Your custom middleware logic goes here | ||
// }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters