Skip to content

Commit 48bfe4e

Browse files
authored
Show SSO-specific error message instead of generic 403 (#930)
If the response indicates that logging in with SSO is required, show a more specific error message ---- By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent 5a002d3 commit 48bfe4e

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

convex/convexProjects.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,9 @@ async function _connectConvexProjectForMember(
274274
const text = await response.text();
275275
const defaultProvisioningError = new ConvexError({
276276
code: "ProvisioningError",
277-
message: `Failed to create project: ${response.status}`,
277+
message: text.includes("SSORequired")
278+
? "You must log in with Single Sign-on to access this team."
279+
: `Failed to create project: ${response.status}`,
278280
details: text,
279281
});
280282
if (response.status !== 400) {
@@ -327,7 +329,9 @@ async function _connectConvexProjectForMember(
327329
const text = await projectDeployKeyResponse.text();
328330
throw new ConvexError({
329331
code: "ProvisioningError",
330-
message: `Failed to create project deploy key: ${projectDeployKeyResponse.status}`,
332+
message: text.includes("SSORequired")
333+
? "You must log in with Single Sign-on to access this team."
334+
: `Failed to create project deploy key: ${projectDeployKeyResponse.status}`,
331335
details: text,
332336
});
333337
}

convex/messages.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,8 @@ async function tryDeleteProject(args: {
643643
const error = JSON.parse(text);
644644
if (error.code === "TeamNotFound") {
645645
return { kind: "error", error: `Team not found: ${teamSlug}` };
646+
} else if (error.code === "SSORequired") {
647+
return { kind: "error", error: `You must log in with Single Sign-on to access this team.` };
646648
}
647649
return { kind: "error", error: `Failed to fetch team projects: ${projectsResponse.statusText} ${text}` };
648650
} catch (_e) {
@@ -663,7 +665,12 @@ async function tryDeleteProject(args: {
663665

664666
if (!response.ok) {
665667
const text = await response.text();
666-
return { kind: "error", error: `Failed to delete project: ${response.statusText} ${text}` };
668+
return {
669+
kind: "error",
670+
error: text.includes("SSORequired")
671+
? `You must log in with Single Sign-on to delete this project.`
672+
: `Failed to delete project: ${response.statusText} ${text}`,
673+
};
667674
}
668675
}
669676

0 commit comments

Comments
 (0)