Skip to content

Commit c926d6e

Browse files
INQTRclaude
andcommitted
fix: redirect Jira authorize errors to dashboard settings with toast
Instead of returning raw plain text responses ("Unauthorized", "Jira integration not configured"), redirect to the dashboard settings page with error query params so users see friendly toast messages. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e203e09 commit c926d6e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/app/api/integrations/jira/authorize/route.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import { cookies } from "next/headers";
2+
import { redirect } from "next/navigation";
23
import { isAuthenticated } from "@/lib/auth-server";
34

45
export async function GET() {
56
const authed = await isAuthenticated();
67
if (!authed) {
7-
return new Response("Unauthorized", { status: 401 });
8+
redirect("/dashboard/settings?tab=integrations&error=jira_unauthorized");
89
}
910

1011
const clientId = process.env.JIRA_CLIENT_ID;
1112
const appUrl = process.env.NEXT_PUBLIC_APP_URL ?? process.env.NEXT_PUBLIC_SITE_URL;
1213

1314
if (!clientId || !appUrl) {
14-
return new Response("Jira integration not configured", { status: 500 });
15+
redirect("/dashboard/settings?tab=integrations&error=jira_not_configured");
1516
}
1617

1718
// CSRF protection: store random state in httpOnly cookie

src/components/dashboard/integrations-settings.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ export function IntegrationsSettings() {
3131
const error = searchParams.get("error");
3232
if (error?.startsWith("jira_")) {
3333
const messages: Record<string, string> = {
34+
jira_unauthorized: "You must be signed in to connect Jira.",
35+
jira_not_configured:
36+
"Jira integration is not configured. Please contact the administrator.",
3437
jira_denied: "Jira authorization was denied.",
3538
jira_invalid: "Invalid callback parameters.",
3639
jira_state_mismatch: "Security check failed. Please try again.",

0 commit comments

Comments
 (0)