Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(auth): improve password reset error messages (#3143)

Marc Klingenb924bf9e09dc
diff --git a/web/src/features/auth-credentials/components/ResetPasswordButton.tsx b/web/src/features/auth-credentials/components/ResetPasswordButton.tsx
index a084dc7d1f..5e80eb2c7b 100644
--- a/web/src/features/auth-credentials/components/ResetPasswordButton.tsx
+++ b/web/src/features/auth-credentials/components/ResetPasswordButton.tsx
@@ -16,6 +16,7 @@ export function RequestResetPasswordEmailButton({
const [isEmailSent, setIsEmailSent] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const [isValidEmail, setIsValidEmail] = useState(false);
+ const [errorMessage, setErrorMessage] = useState<string | null>(null);
const session = useSession();
const capture = usePostHogClientCapture();
@@ -28,35 +29,50 @@ export function RequestResetPasswordEmailButton({
if (!isValidEmail) return;
capture("auth:reset_password_email_requested");
setIsLoading(true);
+ setErrorMessage(null);
try {
- await signIn("email", {
+ const res = await signIn("email", {
email: email,
callbackUrl: "/auth/reset-password",
redirect: false,
});
- setIsEmailSent(true);
+ if (res?.error) {
+ setErrorMessage(
+ res.error === "AccessDenied"
+ ? "This email is not associated with any account."
+ : res.error,
+ );
+ } else if (res?.ok) {
+ setIsEmailSent(true);
+ }
} catch (error) {
console.error("Error sending reset password email:", error);
+ setErrorMessage("An unexpected error occurred. Please try again.");
} finally {
setIsLoading(false);
}
};
return (
- <Button
- onClick={handleResetPassword}
- className={className}
- loading={isLoading}
- disabled={isEmailSent || !isValidEmail}
- variant={variant}
- >
- {isEmailSent
- ? session.status === "authenticated"
+ <>
+ <Button
+ onClick={handleResetPassword}
+ className={className}
+ loading={isLoading}
+ disabled={isEmailSent || !isValidEmail}
+ variant={variant}
+ >
+ {isEmailSent
? "Email sent. Please check your inbox"
- : "Email sent if account exists"
- : session.status === "authenticated"
- ? "Verify email to change password"
- : "Request password reset"}
- </Button>
+ : session.status === "authenticated"
+ ? "Verify email to change password"
+ : "Request password reset"}
+ </Button>
+ {errorMessage && (
+ <div className="mt-3 text-center text-sm text-destructive">
+ {errorMessage}
+ </div>
+ )}
+ </>
);
}
diff --git a/web/src/features/auth-credentials/components/ResetPasswordPage.tsx b/web/src/features/auth-credentials/components/ResetPasswordPage.tsx
index 8cd09acbdd..750e89de7d 100644
--- a/web/src/features/auth-credentials/components/ResetPasswordPage.tsx
+++ b/web/src/features/auth-credentials/components/ResetPasswordPage.tsx
@@ -16,7 +16,7 @@ import { Input } from "@/src/components/ui/input";
import { PasswordInput } from "@/src/components/ui/password-input";
import { LangfuseIcon } from "@/src/components/LangfuseLogo";
import { useSession } from "next-auth/react";
-import { ShieldCheck } from "lucide-react";
+import { ArrowLeft, ShieldCheck } from "lucide-react";
import { api } from "@/src/utils/api";
import { useRouter } from "next/router";
import { RequestResetPasswordEmailButton } from "@/src/features/auth-credentials/components/ResetPasswordButton";
@@ -122,9 +122,19 @@ export function ResetPasswordPage({
<h2 className="mt-4 text-center text-2xl font-bold leading-9 tracking-tight text-primary">
Reset your password
</h2>
+ {session.status !== "authenticated" && (
+ <div className="mt-2 flex justify-center">
+ <Button asChild variant="ghost">
+ <Link href="/auth/sign-in">
+ <ArrowLeft className="mr-2 h-3 w-3" />
+ Back to sign in
+ </Link>
+ </Button>
+ </div>
+ )}
</div>
- <div className="mt-14 bg-background px-6 py-10 shadow sm:mx-auto sm:w-full sm:max-w-[480px] sm:rounded-lg sm:px-12">
+ <div className="mt-10 bg-background px-6 py-10 shadow sm:mx-auto sm:w-full sm:max-w-[480px] sm:rounded-lg sm:px-12">
<div className="space-y-6">
<Form {...form}>
<form
diff --git a/web/src/features/organizations/components/ProjectOverview.tsx b/web/src/features/organizations/components/ProjectOverview.tsx
index d4025ca1e2..33fb1c22c6 100644
--- a/web/src/features/organizations/components/ProjectOverview.tsx
+++ b/web/src/features/organizations/components/ProjectOverview.tsx
@@ -2,6 +2,7 @@ import { Building2, LifeBuoy, LockIcon, Settings, Users } from "lucide-react";
import {
Card,
CardContent,
+ CardDescription,
CardFooter,
CardHeader,
CardTitle,
@@ -251,9 +252,11 @@ const Onboarding = () => {
</CardTitle>
</CardHeader>
<CardContent>
- {canCreateOrgs
- ? "Create an organization to get started. Alternatively, ask your organization admin to invite you."
- : "You need to get invited to an organization to get started with Langfuse."}
+ <CardDescription>
+ {canCreateOrgs
+ ? "Create an organization to get started. Alternatively, ask your organization admin to invite you."
+ : "You need to get invited to an organization to get started with Langfuse."}
+ </CardDescription>
</CardContent>
<CardFooter className="flex gap-4">
{canCreateOrgs && (