Skip to content
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

Merged
merged 15 commits into from
May 17, 2024
Merged

Conversation

kgilles
Copy link
Member

@kgilles kgilles commented May 16, 2024

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.

@kgilles kgilles requested a review from a team as a code owner May 16, 2024 21:16
@kgilles kgilles linked an issue May 16, 2024 that may be closed by this pull request
Copy link
Member

@lazyguru lazyguru left a 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');
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Created #154

@kgilles kgilles merged commit ce3574b into main May 17, 2024
5 checks passed
@kgilles kgilles deleted the 149-create-auth-restricted-routes branch May 17, 2024 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create auth-restricted routes
3 participants