inlines secret fetching for auth to remove postinstall step
This commit is contained in:
parent
5f2243b49a
commit
545656cf22
@ -5,14 +5,21 @@ import Credentials from "next-auth/providers/credentials";
|
|||||||
import Discord from "next-auth/providers/discord";
|
import Discord from "next-auth/providers/discord";
|
||||||
|
|
||||||
import bcrypt from "bcryptjs";
|
import bcrypt from "bcryptjs";
|
||||||
|
import { SecretClient } from "@/lib/secret/init";
|
||||||
|
|
||||||
const prisma = new PrismaClient();
|
const prisma = new PrismaClient();
|
||||||
|
|
||||||
export const { handlers, signIn, signOut, auth } = NextAuth({
|
export const { handlers, signIn, signOut, auth } = NextAuth(async () => {
|
||||||
|
const sClient = SecretClient();
|
||||||
|
|
||||||
|
const clientId = await sClient.fetchSecret("discord_client_id");
|
||||||
|
const clientSecret = await sClient.fetchSecret("discord_client_secret");
|
||||||
|
|
||||||
|
return {
|
||||||
providers: [
|
providers: [
|
||||||
Discord({
|
Discord({
|
||||||
clientId: process.env.DISCORD_CLIENT_ID,
|
clientId,
|
||||||
clientSecret: process.env.DISCORD_CLIENT_SECRET,
|
clientSecret,
|
||||||
}),
|
}),
|
||||||
Credentials({
|
Credentials({
|
||||||
credentials: {
|
credentials: {
|
||||||
@ -63,6 +70,7 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
|
|||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
adapter: PrismaAdapter(prisma),
|
adapter: PrismaAdapter(prisma),
|
||||||
|
};
|
||||||
});
|
});
|
||||||
async function saltAndHashPassword(password: string) {
|
async function saltAndHashPassword(password: string) {
|
||||||
const hash = await bcrypt.hash(password, 10);
|
const hash = await bcrypt.hash(password, 10);
|
||||||
|
@ -5,8 +5,8 @@ if (!globalThis.Secrets) {
|
|||||||
"https://dragonshoard.cyborggrizzly.com",
|
"https://dragonshoard.cyborggrizzly.com",
|
||||||
process.env.NODE_ENV === "development"
|
process.env.NODE_ENV === "development"
|
||||||
? "./.dragonshoard"
|
? "./.dragonshoard"
|
||||||
: "/.dragonshoard",
|
: "/.dragonshoard"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SecretClient = () => globalThis.Secrets;
|
export const SecretClient = (): DHSecretClient => globalThis.Secrets;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user