Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- [EE] Fixed missing account-linking prompts during OAuth authorization and restored prompts when new optional providers are configured. [#1663](https://github.com/sourcebot-dev/sourcebot/pull/1663)
- Prevented browser performance instrumentation from breaking code views when `performance.measure()` returns no value. [#1665](https://github.com/sourcebot-dev/sourcebot/pull/1665)
- Added specific authentication error messages and recovery guidance shared by the login form and error page. [#1669](https://github.com/sourcebot-dev/sourcebot/pull/1669)

## [5.1.13] - 2026-09-12

Expand Down
15 changes: 2 additions & 13 deletions packages/web/src/app/login/components/loginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import useCaptureEvent from "@/hooks/useCaptureEvent";
import { useIdentityProviders } from "@/features/auth/useIdentityProviders";
import Link from "next/link";
import { LoginMessage } from "@/features/auth/components/loginMessage";
import { getAuthErrorContent } from "@/features/auth/errorMessages";

interface LoginFormProps {
callbackUrl?: string;
Expand All @@ -31,19 +32,7 @@ export const LoginForm = ({ callbackUrl, error, context, isAnonymousAccessEnable
return "/";
}, [callbackUrl]);

const errorMessage = useMemo(() => {
if (!error) {
return "";
}
switch (error) {
case "CredentialsSignin":
return "Invalid email or password. Please try again.";
case "OAuthAccountNotLinked":
return "This email is already associated with a different sign-in method.";
default:
return "An error occurred during authentication. Please try again.";
}
}, [error]);
const errorMessage = getAuthErrorContent(error).description;

// Helper function to get the correct analytics event name based on provider type.
const getLoginEventName = (providerType: string) => {
Expand Down
28 changes: 2 additions & 26 deletions packages/web/src/app/login/error/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,11 @@ import Link from "next/link"
import { SourcebotLogo } from "@/app/components/sourcebotLogo"
import { Footer } from "@/app/components/footer"
import { SOURCEBOT_SUPPORT_EMAIL } from "@/lib/constants"

// @see https://authjs.dev/guides/pages/error
const ERROR_CONTENT: Record<string, { title: string; description: string }> = {
Configuration: {
title: "Server configuration error",
description: "There is a problem with the server's authentication configuration. Please contact your administrator.",
},
AccessDenied: {
title: "Access denied",
description: "You do not have permission to sign in.",
},
EmailRequired: {
title: "No email on your account",
description: "Your identity provider didn't share an email address, which Sourcebot requires to sign you in. Add or verify an email on your upstream account, then try again.",
},
Verification: {
title: "This sign-in link has expired",
description: "The code or link you used is no longer valid - it may have expired or already been used. Request a new one and try again.",
},
Default: {
title: "Unable to sign in",
description: "Something went wrong while signing you in. Please try again.",
},
}
import { getAuthErrorContent } from "@/features/auth/errorMessages"

function ErrorPageContent() {
const searchParams = useSearchParams()
const error = searchParams.get("error") ?? "Default"
const { title, description } = ERROR_CONTENT[error] ?? ERROR_CONTENT.Default
const { title, description } = getAuthErrorContent(searchParams.get("error"))

return (
<div className="flex flex-col min-h-screen">
Expand Down
49 changes: 49 additions & 0 deletions packages/web/src/features/auth/errorMessages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const ERROR_CONTENT: Record<string, { title: string; description: string }> = {
CredentialsSignin: {
title: "Unable to sign in",
description: "Invalid email or password. Please try again.",
},
OAuthAccountNotLinked: {
title: "Different sign-in method required",
description: "This email is already associated with a different sign-in method.",
},
OAuthCallbackError: {
title: "Provider sign-in failed",
description: "Sign-in with your identity provider was cancelled or could not be completed. Please try again. If this continues, contact your administrator.",
},
MissingCSRF: {
title: "Sign-in security check failed",
description: "We couldn't verify your sign-in request. Refresh the page and try again.",
},
AccountNotLinked: {
title: "Account not linked",
description: "This account isn't linked to your Sourcebot user. Sign in using your original method, then link the account in Settings.",
},
WebAuthnVerificationError: {
title: "Passkey verification failed",
description: "We couldn't verify your passkey. Please try again or use another available sign-in method.",
},
Configuration: {
title: "Server configuration error",
description: "There is a problem with the server's authentication configuration. Please contact your administrator.",
},
AccessDenied: {
title: "Access denied",
description: "You do not have permission to sign in.",
},
EmailRequired: {
title: "No email on your account",
description: "Your identity provider didn't share an email address, which Sourcebot requires to sign you in. Add or verify an email on your upstream account, then try again.",
},
Verification: {
title: "This sign-in link has expired",
description: "The code or link you used is no longer valid - it may have expired or already been used. Request a new one and try again.",
},
Default: {
title: "Unable to sign in",
description: "An error occurred during authentication. Please try again.",
},
};

export const getAuthErrorContent = (error: string | null | undefined) =>
error && Object.hasOwn(ERROR_CONTENT, error) ? ERROR_CONTENT[error] : ERROR_CONTENT.Default;
Loading