fix(onboarding): step-login — conform to global mutation pattern, handle SSO errors

This commit is contained in:
Théo LAGACHE
2026-06-18 11:22:26 +02:00
parent 642e6c7fde
commit 17b9d1da02
+15 -13
View File
@@ -35,23 +35,25 @@ export const StepLogin = () => {
const loginMutation = useMutation({ const loginMutation = useMutation({
mutationFn: async (values: LoginValues) => { mutationFn: async (values: LoginValues) => {
const result = await signIn.email( const result = await signIn.email({
{ email: values.email, password: values.password }, email: values.email,
{ password: values.password,
onSuccess: async () => { });
await next(); if (result.error) throw new Error(result.error.message ?? "Sign in failed");
}, await next();
onError: (error) => { return result.data;
toast.error(error.error.message); },
}, onError: (err: Error) => {
} toast.error(err.message);
);
return result;
}, },
}); });
const handleSso = async (providerId: string) => { const handleSso = async (providerId: string) => {
await signIn.social({ provider: providerId as any }); try {
await signIn.social({ provider: providerId as any });
} catch (err) {
toast.error(err instanceof Error ? err.message : "SSO sign in failed");
}
}; };
// Case 1: No existing users — registration flow (SSO or continue to account-info) // Case 1: No existing users — registration flow (SSO or continue to account-info)