29 lines
972 B
TypeScript
29 lines
972 B
TypeScript
import NextAuth, { NextAuthConfig } from 'next-auth';
|
|
import GoogleProvider from 'next-auth/providers/google';
|
|
|
|
export const authConfig:NextAuthConfig = {
|
|
callbacks: {
|
|
async signIn({ account, profile }) {
|
|
if (account?.provider === "google") {
|
|
return profile?.email_verified === true && profile?.email?.endsWith("@google.com") === true
|
|
}
|
|
return true // Do different verification for other providers that don't have `email_verified`
|
|
},
|
|
authorized({ auth, request: { nextUrl } }) {
|
|
const isLoggedIn = !!auth?.user;
|
|
return(isLoggedIn);
|
|
},
|
|
},
|
|
providers: [
|
|
GoogleProvider({
|
|
clientId: process.env.GOOGLE_ID,
|
|
clientSecret: process.env.GOOGLE_SECRET,
|
|
}),
|
|
],
|
|
session: {
|
|
// Use JSON Web Tokens for session instead of database sessions.
|
|
// This option can be used with or without a database for users/accounts.
|
|
// Note: `jwt` is automatically set to `true` if no database is specified.
|
|
strategy: 'jwt'
|
|
},
|
|
}; |