From a99a02223dcdb5d53b1e5f3b377224ae8353ab44 Mon Sep 17 00:00:00 2001 From: Brace Sproul Date: Thu, 12 Jun 2025 11:12:00 -0700 Subject: [PATCH] fix: Disconnect GH -> Logout button (#138) * fix: Disconnect GH -> Logout button * cr --- .../src/components/github/github-oauth-button.tsx | 13 ++++++++----- apps/web/src/components/github/open-pr-button.tsx | 1 + apps/web/src/lib/auth.ts | 8 +++----- apps/web/src/utils/github.ts | 6 +++++- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/apps/web/src/components/github/github-oauth-button.tsx b/apps/web/src/components/github/github-oauth-button.tsx index 4fec1e3d..dfe633b7 100644 --- a/apps/web/src/components/github/github-oauth-button.tsx +++ b/apps/web/src/components/github/github-oauth-button.tsx @@ -3,6 +3,8 @@ import { useState, useEffect } from "react"; import { Button } from "@/components/ui/button"; import { GitHubSVG } from "@/components/icons/github"; +import { LogOut } from "lucide-react"; +import { TooltipIconButton } from "../ui/tooltip-icon-button"; export function GitHubOAuthButton() { const [isAuth, setIsAuth] = useState(null); @@ -35,7 +37,9 @@ export function GitHubOAuthButton() { method: "POST", }); if (response.ok) { + localStorage.removeItem("github_app_installed"); setIsAuth(false); + window.location.href = "/"; } else { console.error("Logout failed"); } @@ -65,16 +69,15 @@ export function GitHubOAuthButton() { if (isAuth) { return ( - + + ); } diff --git a/apps/web/src/components/github/open-pr-button.tsx b/apps/web/src/components/github/open-pr-button.tsx index e6527efa..aba83cf5 100644 --- a/apps/web/src/components/github/open-pr-button.tsx +++ b/apps/web/src/components/github/open-pr-button.tsx @@ -70,6 +70,7 @@ export function OpenPRButton() { "text-gray-500 hover:text-gray-600": prState === "draft", "text-[#8957e5] hover:text-[#7847d1]": prState === "merged", })} + size="sm" > {prState === "merged" && } {prState === "draft" && } diff --git a/apps/web/src/lib/auth.ts b/apps/web/src/lib/auth.ts index 986be09d..96c3ed03 100644 --- a/apps/web/src/lib/auth.ts +++ b/apps/web/src/lib/auth.ts @@ -95,11 +95,9 @@ export function getGitHubToken(request: NextRequest): GitHubTokenData | null { * @param response NextResponse to set cookies on */ export function clearGitHubToken(response: NextResponse): void { - const cookieOptions = getCookieOptions(new Date(0)); // Expire immediately - - response.cookies.set(GITHUB_TOKEN_COOKIE, "", cookieOptions); - response.cookies.set(GITHUB_TOKEN_TYPE_COOKIE, "", cookieOptions); - response.cookies.set(GITHUB_INSTALLATION_ID_COOKIE, "", cookieOptions); + response.cookies.delete(GITHUB_TOKEN_COOKIE); + response.cookies.delete(GITHUB_TOKEN_TYPE_COOKIE); + response.cookies.delete(GITHUB_INSTALLATION_ID_COOKIE); } /** diff --git a/apps/web/src/utils/github.ts b/apps/web/src/utils/github.ts index 9cebc664..6fab6331 100644 --- a/apps/web/src/utils/github.ts +++ b/apps/web/src/utils/github.ts @@ -249,8 +249,12 @@ export async function getPullRequest(inputs: { headBranch: string; }) { try { + const queryParams = new URLSearchParams(); + queryParams.set("base", inputs.baseBranch); + queryParams.set("head", inputs.headBranch); + queryParams.set("state", "all"); const response = await fetch( - `${getBaseApiUrl()}github/proxy/repos/${inputs.owner}/${inputs.repo}/pulls?base=${inputs.baseBranch}&head=${inputs.headBranch}`, + `${getBaseApiUrl()}github/proxy/repos/${inputs.owner}/${inputs.repo}/pulls?${queryParams.toString()}`, { headers: { Accept: "application/vnd.github.v3+json",