diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..3ae7eb2 --- /dev/null +++ b/.env.example @@ -0,0 +1,7 @@ +NEXTAUTH_URL=https://tomodachishare.trafficlunar.net +AUTH_SECRET=XXXXXXXXXXXXXXXX + +DISCORD_ID=XXXXXXXXXXXXXXXX +DISCORD_SECRET=XXXXXXXXXXXXXXXX +GITHUB_ID=XXXXXXXXXXXXXXXX +GITHUB_SECRET=XXXXXXXXXXXXXXXX \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5ef6a52..7b8da95 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ yarn-error.log* # env files (can opt-in for committing if needed) .env* +!.env.example # vercel .vercel diff --git a/src/app/api/auth/[...nextauth]/route.ts b/src/app/api/auth/[...nextauth]/route.ts new file mode 100644 index 0000000..2ea33c3 --- /dev/null +++ b/src/app/api/auth/[...nextauth]/route.ts @@ -0,0 +1,23 @@ +import NextAuth, { AuthOptions } from "next-auth"; +import Discord from "next-auth/providers/discord"; +import Github from "next-auth/providers/github"; + +export const authOptions: AuthOptions = { + pages: { + signIn: "/login", + }, + providers: [ + Discord({ + clientId: process.env.DISCORD_ID!, + clientSecret: process.env.DISCORD_SECRET!, + }), + Github({ + clientId: process.env.GITHUB_ID!, + clientSecret: process.env.GITHUB_SECRET!, + }), + ], +}; + +const handler = NextAuth(authOptions); + +export { handler as GET, handler as POST }; diff --git a/src/app/components/login-buttons.tsx b/src/app/components/login-buttons.tsx new file mode 100644 index 0000000..2c3c4b5 --- /dev/null +++ b/src/app/components/login-buttons.tsx @@ -0,0 +1,19 @@ +"use client"; + +import { Icon } from "@iconify/react/dist/iconify.js"; +import { signIn } from "next-auth/react"; + +export default function LoginButtons() { + return ( +