-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create auth-restricted pages #153
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than my 1 comment (and that I'm not in the frontend dev team), lgtm
|
||
const validation = await SublinksApi.Instance().Client().validateAuth(); | ||
if (!validation.success) { | ||
redirect('/login'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future we should add a query parameter to here, where he wanted to go before getting redirected to login.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Created #154
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.