-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
97489ae
commit 6b62ee1
Showing
112 changed files
with
1,617 additions
and
1,578 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
titleOnly: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Check code style | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
run-checks: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup pnpm | ||
uses: pnpm/action-setup@v4.0.0 | ||
- name: Setup Node | ||
uses: actions/setup-node@v4.0.3 | ||
with: | ||
node-version-file: .nvmrc | ||
- run: pnpm i --frozen-lockfile | ||
|
||
- name: Checking format | ||
run: pnpm run format:check | ||
- name: Run lint | ||
run: pnpm run lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v20.15.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"semi": false, | ||
"plugins": ["prettier-plugin-tailwindcss"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,51 @@ | ||
"use server"; | ||
"use server" | ||
|
||
import { revalidatePath } from "next/cache"; | ||
import { redirect } from "next/navigation"; | ||
import { revalidatePath } from "next/cache" | ||
import { redirect } from "next/navigation" | ||
|
||
import { createClient } from "@/lib/supabase/server"; | ||
import { cookies, headers } from "next/headers"; | ||
import { createClient } from "@/lib/supabase/server" | ||
import { cookies, headers } from "next/headers" | ||
import { | ||
GITHUB_REFRESH_TOKEN_COOKIE, | ||
GITHUB_ACCESS_TOKEN_COOKIE, | ||
} from "@/lib/supabase/cookies"; | ||
} from "@/lib/supabase/cookies" | ||
|
||
export async function login() { | ||
"use server"; | ||
const origin = headers().get("origin"); | ||
const supabase = createClient(); | ||
"use server" | ||
const origin = headers().get("origin") | ||
const supabase = createClient() | ||
|
||
const { error, data } = await supabase.auth.signInWithOAuth({ | ||
provider: "github", | ||
options: { | ||
redirectTo: `${origin}/auth/callback`, | ||
}, | ||
}); | ||
}) | ||
|
||
if (error) { | ||
redirect("/error"); | ||
redirect("/error") | ||
} | ||
|
||
revalidatePath("/", "layout"); | ||
redirect(data.url); | ||
revalidatePath("/", "layout") | ||
redirect(data.url) | ||
} | ||
|
||
export async function logout() { | ||
"use server"; | ||
const supabase = createClient(); | ||
"use server" | ||
const supabase = createClient() | ||
|
||
const { | ||
data: { user }, | ||
} = await supabase.auth.getUser(); | ||
} = await supabase.auth.getUser() | ||
|
||
if (user) { | ||
await supabase.auth.signOut(); | ||
await supabase.auth.signOut() | ||
} | ||
|
||
const cookieStore = cookies(); | ||
cookieStore.delete(GITHUB_ACCESS_TOKEN_COOKIE); | ||
cookieStore.delete(GITHUB_REFRESH_TOKEN_COOKIE); | ||
const cookieStore = cookies() | ||
cookieStore.delete(GITHUB_ACCESS_TOKEN_COOKIE) | ||
cookieStore.delete(GITHUB_REFRESH_TOKEN_COOKIE) | ||
|
||
revalidatePath("/", "layout"); | ||
redirect("/"); | ||
revalidatePath("/", "layout") | ||
redirect("/") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
import { | ||
GITHUB_REFRESH_TOKEN_COOKIE, | ||
GITHUB_ACCESS_TOKEN_COOKIE, | ||
} from "@/lib/supabase/cookies"; | ||
import { createClient } from "@/lib/supabase/server"; | ||
import { createServerClient } from "@supabase/ssr"; | ||
import { cookies } from "next/headers"; | ||
import { NextResponse } from "next/server"; | ||
} from "@/lib/supabase/cookies" | ||
import { createClient } from "@/lib/supabase/server" | ||
import { createServerClient } from "@supabase/ssr" | ||
import { cookies } from "next/headers" | ||
import { NextResponse } from "next/server" | ||
|
||
export async function GET(request: Request) { | ||
const { searchParams, origin } = new URL(request.url); | ||
const code = searchParams.get("code"); | ||
const { searchParams, origin } = new URL(request.url) | ||
const code = searchParams.get("code") | ||
// if "next" is in param, use it as the redirect URL | ||
const next = searchParams.get("next") ?? "/dashboard"; | ||
const next = searchParams.get("next") ?? "/dashboard" | ||
|
||
if (code) { | ||
const cookieStore = cookies(); | ||
const supabase = createClient(); | ||
const cookieStore = cookies() | ||
const supabase = createClient() | ||
|
||
supabase.auth.onAuthStateChange((event, session) => { | ||
if (session && session.provider_token) { | ||
cookieStore.set(GITHUB_ACCESS_TOKEN_COOKIE, session.provider_token); | ||
cookieStore.set(GITHUB_ACCESS_TOKEN_COOKIE, session.provider_token) | ||
} | ||
|
||
if (session && session.provider_refresh_token) { | ||
cookieStore.set( | ||
GITHUB_REFRESH_TOKEN_COOKIE, | ||
session.provider_refresh_token, | ||
{ expires: new Date().setMonth(new Date().getMonth() + 3) }, | ||
); | ||
) | ||
} | ||
|
||
if (event === "SIGNED_OUT") { | ||
cookieStore.delete(GITHUB_ACCESS_TOKEN_COOKIE); | ||
cookieStore.delete(GITHUB_REFRESH_TOKEN_COOKIE); | ||
cookieStore.delete(GITHUB_ACCESS_TOKEN_COOKIE) | ||
cookieStore.delete(GITHUB_REFRESH_TOKEN_COOKIE) | ||
} | ||
}); | ||
}) | ||
|
||
const { error } = await supabase.auth.exchangeCodeForSession(code); | ||
const { error } = await supabase.auth.exchangeCodeForSession(code) | ||
if (!error) { | ||
return NextResponse.redirect(`${origin}${next}`); | ||
return NextResponse.redirect(`${origin}${next}`) | ||
} | ||
} | ||
|
||
// return the user to an error page with instructions | ||
return NextResponse.redirect(`${origin}/auth/auth-code-error`); | ||
return NextResponse.redirect(`${origin}/auth/auth-code-error`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { createClient } from "@/lib/supabase/server"; | ||
import { NextResponse } from "next/server"; | ||
import { createClient } from "@/lib/supabase/server" | ||
import { NextResponse } from "next/server" | ||
|
||
export async function GET(request: Request) { | ||
await createClient().auth.signOut(); | ||
await createClient().auth.signOut() | ||
|
||
const { origin } = new URL(request.url); | ||
const { origin } = new URL(request.url) | ||
|
||
return NextResponse.redirect(origin); | ||
return NextResponse.redirect(origin) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export default function Default() { | ||
return null; | ||
return null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.