SaasUiAuth Supabase password login redirect not working
alexleetc28 opened this issue · 2 comments
Description
When I use SaasUiAuth with Supabase for password login, I expect to be redirected after logging in, but instead, nothing happens.
I think the reason is that Supabase's signInWithPassword
doesn't have a redirect option like OAuth login does. Therefore, I believe SaasUI needs to add handling for redirects for Supabase password login. Otherwise, the user will be stuck on the Auth page when using password login.
Ref:
Link to Reproduction
No response
Steps to reproduce
providers.tsx:
const authService = createAuthService(supabase, {
loginOptions: {
redirectTo: "/dashboard",
},
});
export const RootProviders = ({ children }: { children: React.ReactNode }) => (
<SaasProvider theme={theme}>
<AuthProvider {...authService}>{children}</AuthProvider>
</SaasProvider>
);
components/Auth/index.tsx:
<SaasUiAuth
providers={{
azure: {
icon: FaMicrosoft,
name: "Azure",
},
}}
type="password"
onError={(view, error) => {
if (error)
snackbar.error({
title: error.message,
variant: "left-accent",
duration: 10000,
isClosable: true,
});
}}
redirectUrl={getAbsoluteUrl(redirectUrl)}
/>
Saas UI Version
2.8.2
Chakra UI Version
No response
Browser
No response
Operating System
- macOS
- Windows
- Linux
Additional Information
No response
Thanks for your feedback!
This option might be a bit confusing, you might expect it to always redirect. But in case of password login it's the responsibility of the user to set it up.
You can use the onSuccess
handler or check isAuthenticated
in useEffect
to redirect away from the login page ones a user is logged in.