diff --git a/.env.example b/.env.example index a1565d7..dc00890 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,7 @@ DATABASE_URL="postgresql://admin:admin@localhost:5432/cooper?schema=public" -NEXTAUTH_URL="localhost:3000" \ No newline at end of file + +NEXTAUTH_URL="http://localhost:3000" +NEXTAUTH_SECRET= + +GOOGLE_CLIENT_ID= +GOOGLE_CLIENT_SECRET= \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c31eb4d..3e31a5b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,9 +10,12 @@ env: NODE_VERSION: 20 PNPM_VERSION: 8 - # Find a workaround to this. + # Find a workaround for this. DATABASE_URL: "postgresql://admin:admin@localhost:5432/cooper?schema=public" NEXTAUTH_URL: "localhost:3000" + NEXTAUTH_SECRET: "sec" + GOOGLE_CLIENT_ID: "cooper" + GOOGLE_CLIENT_SECRET: "cooper" jobs: lint: diff --git a/README.md b/README.md index ae21254..003d640 100644 --- a/README.md +++ b/README.md @@ -72,5 +72,16 @@ cp .env.example .env ```env DATABASE_URL="postgresql://admin:admin@localhost:5432/cooper?schema=public" -NEXTAUTH_URL="localhost:3000" + +NEXTAUTH_URL="http://localhost:3000" +NEXTAUTH_SECRET= + +GOOGLE_CLIENT_ID= +GOOGLE_CLIENT_SECRET= +``` + +To generate `GOOGLE_CLIENT_ID` and `GOOGLE_CLIENT_SECRET`, see [Setting up OAuth 2.0](https://support.google.com/cloud/answer/6158849?hl=en). To generate a new `NEXTAUTH_SECRET`, run the following command in your terminal and add it to the `.env` file. + +```bash +openssl rand -base64 32 ``` diff --git a/src/app/page.tsx b/src/app/page.tsx index 2801364..6b8abe8 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,3 +1,51 @@ +import { redirect } from "next/navigation"; +import { getServerAuthSession } from "~/server/auth"; + export default async function Home() { - return
+ You are not signed in! +
+ + + Sign in with Google + ++ Welcome, {session.user.name}! +
+ + Sign Out + +