mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
fix(onboarding): step-login — conform to global mutation pattern, handle SSO errors
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user