saas-js / saas-ui

The React component library for startups, built with Chakra UI.
https://saas-ui.dev
MIT License
1.32k stars 128 forks source link

Auth component's prop types are incomplet #200

Closed lwolle closed 8 months ago

lwolle commented 8 months ago

First of all, thank you for the great project. It's a really nice extension of chakra-ui and complements it really well.

The Auth component is awesome, I'm using it in conjunction with the supabase-client integration. After successful (onSuccess login, I'd like to navigate to a specific route, and the redirect URL doesn't appear to do the trick, and I'd like to work with my custom router. So I've looked into the components props and onSuccess is forwarded to all views, but the types and the documentation do not mention it. Is there some reasoning behind that?

And it would be lovely, if you could provide an issue template as mentioned in the Contribution Guidelines

linear[bot] commented 8 months ago

SUI-395 Auth component's prop types are incomplet

Pagebakers commented 8 months ago

Thanks for the kind words!

onSuccess and onValidationError aren't officially exposed through the Auth component, although they would be forwarded to the internal forms if you add these props.

Another way to redirect after log in would be something like this on your log in component.

const { isAuthenticated, isLoggingIn } = useAuth()

useEffect(() => {
  if (!isLoggingIn && isAuthenticated) {
    router.push('/path')
  }
}, [isAuthenticated, isLoggingIn])

I've updated the template, thanks for the suggestion!

lwolle commented 8 months ago

Thank's for the response. I'd take a look, but I felt that reacting to onSuccess would be a clean way to achieve it.

Pagebakers commented 8 months ago

Yes i agree it is, I'm going to take this feedback into account with the refactoring of the auth services I'm working on.