sublinks / sublinks-frontend

MIT License
17 stars 5 forks source link

Create auth-restricted pages #153

Closed kgilles closed 3 months ago

kgilles commented 3 months ago

This PR introduces the concept of restricted pages. Currently to prevent unauthorized users from seeing the post-creation and community-creation pages. When a unauthed user attempts to visit those pages they'll instead be directed to the login page.

To make this work we're using an experimental NextJS option that allows us to run server actions more freely. And this is used to revalidate all routes to make sure NextJS doesn't cache pages too hard and makes it seem like the user is still logged in after logging out, and vice versa.

We also catch up with the JS client and latest cross-fetch.

As an extra bonus this also changes our forms from using the default onSubmit to using React form actions to which the form data is passed in for us.