Adding another service in the frontend-dev docker compose configuration to make it easier to do email based login. Also adding env variables that work by default with the docker services

This commit is contained in:
Keith Stevens
2022-12-20 15:55:14 +09:00
parent 925b51d82d
commit 8e1c280bd7
5 changed files with 81 additions and 21 deletions
+37 -12
View File
@@ -5,16 +5,12 @@ import { PrismaAdapter } from "@next-auth/prisma-adapter";
import prisma from "src/lib/prismadb";
export const authOptions = {
// Ensure we can store user data in a database.
adapter: PrismaAdapter(prisma),
providers: [
// Register a Discord auth method.
DiscordProvider({
clientId: process.env.DISCORD_CLIENT_ID,
clientSecret: process.env.DISCORD_CLIENT_SECRET,
}),
// Register an email magic link auth method.
const providers = [];
console.log(process.env);
// Register an email magic link auth method.
if (process.env.NODE_ENV === "production") {
providers.push(
EmailProvider({
server: {
host: process.env.EMAIL_SERVER_HOST,
@@ -25,8 +21,37 @@ export const authOptions = {
},
},
from: process.env.EMAIL_FROM,
}),
],
})
);
} else {
// Register an email magic link auth method.
providers.push(
EmailProvider({
server: {
host: process.env.EMAIL_SERVER_HOST,
port: process.env.EMAIL_SERVER_PORT,
},
from: process.env.EMAIL_FROM,
async generateVerificationToken() {
return "1234";
},
})
);
}
if (process.env.DISCORD_CLIENT_ID) {
providers.push(
DiscordProvider({
clientId: process.env.DISCORD_CLIENT_ID,
clientSecret: process.env.DISCORD_CLIENT_SECRET,
})
);
}
export const authOptions = {
// Ensure we can store user data in a database.
adapter: PrismaAdapter(prisma),
providers,
pages: {
signIn: "/auth/signin",
},