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({
mutationFn: async (values: LoginValues) => {
const result = await signIn.email(
{ email: values.email, password: values.password },
{
onSuccess: async () => {
await next();
},
onError: (error) => {
toast.error(error.error.message);
},
}
);
return result;
const result = await signIn.email({
email: values.email,
password: values.password,
});
if (result.error) throw new Error(result.error.message ?? "Sign in failed");
await next();
return result.data;
},
onError: (err: Error) => {
toast.error(err.message);
},
});
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)