How do you redirect someone after logging in?

I’m using Supabase Auth. When unauthenticated users try to access a page that requires log-in, the Supabase auth plugin redirects them to the sign in page.

How do I redirect them back to the page they came from after signing in? Any tips / demos?

Hi @Matthew ,

You can use the

navigate to previous page

in the actions when you are in a WF

Thanks for the note! However, I tried that but it just takes everyone back to the home page instead of the last page. Any other ideas?

I am personally not using Supabase but i do the redirection in the workflow of the login form.

You have a video here on weweb/supabase auth:

May be it can help you!

Usually you get a hint where you were redirected in the url as a hash, or a query parameter. Based on that you should be able to do whatever you need to do.

Thx all, however do you have this issue to? It seems the redirect works if they got redirected from an action within the website, but if it’s a redirect from a direct URL it does NOT properly redirect them.

For example:

  1. User types in www.example.com/authenticated-page
  2. That redirects them to www.example.com/login
  3. They login, and are NOT redirected back to /authenticated-page

Thoughts?

This is how I have mine set up. I have multiple roles people can login with. Each role goes to a different section of my app.

“standard-user”
“company-user”
“company-admin”

I use the true/false splits to ask which role the person is and direct them to the correct page.
The role is fetched from the users profile that matches the ID of the auth id.

Does this make sense?

If you only have one login role just use a “navigate to” after the “sign in”