mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
fix: set cookie path and add error feedback on claim failure
This commit is contained in:
parent
2bc6dc5cad
commit
1f8d23ec5b
1 changed files with 11 additions and 1 deletions
|
|
@ -14,6 +14,7 @@ export function OnboardingForm({ variant }: OnboardingFormProps) {
|
|||
const [form] = Form.useForm();
|
||||
const searchParams = useSearchParams()!;
|
||||
const inviteId = searchParams.get("invitation_id");
|
||||
const [claimError, setClaimError] = React.useState<string | null>(null);
|
||||
|
||||
const {
|
||||
data: credentialsData,
|
||||
|
|
@ -38,16 +39,21 @@ export function OnboardingForm({ variant }: OnboardingFormProps) {
|
|||
const handleSubmit = (formValues: { password: string }) => {
|
||||
if (!accessToken || !jwtToken || !userId || !inviteId) return;
|
||||
|
||||
setClaimError(null);
|
||||
|
||||
claimToken(
|
||||
{ accessToken, inviteId, userId, password: formValues.password },
|
||||
{
|
||||
onSuccess: () => {
|
||||
document.cookie = "token=" + jwtToken;
|
||||
document.cookie = `token=${jwtToken}; path=/; SameSite=Lax`;
|
||||
const proxyBaseUrl = getProxyBaseUrl();
|
||||
window.location.href = proxyBaseUrl
|
||||
? `${proxyBaseUrl}/ui/?login=success`
|
||||
: "/ui/?login=success";
|
||||
},
|
||||
onError: (error: Error) => {
|
||||
setClaimError(error.message || "Failed to submit. Please try again.");
|
||||
},
|
||||
}
|
||||
);
|
||||
};
|
||||
|
|
@ -128,6 +134,10 @@ export function OnboardingForm({ variant }: OnboardingFormProps) {
|
|||
<Input.Password />
|
||||
</Form.Item>
|
||||
|
||||
{claimError && (
|
||||
<Alert type="error" message={claimError} showIcon className="mb-4" />
|
||||
)}
|
||||
|
||||
<div className="mt-10">
|
||||
<Button htmlType="submit" loading={isPending}>
|
||||
{variant === "reset_password" ? "Reset Password" : "Sign Up"}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue