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

Make auth optional in withAuthRequired (withAuth ?) #74

Closed
dabarrell opened this issue Apr 18, 2022 · 3 comments · Fixed by #92
Closed

Make auth optional in withAuthRequired (withAuth ?) #74

dabarrell opened this issue Apr 18, 2022 · 3 comments · Fixed by #92
Labels
enhancement New feature or request nextjs Next.js specific functionality

Comments

@dabarrell
Copy link

The withAuthRequired helper is useful for pages which should only be accessed by authenticated users, but there is a use-case for pages which are public, but could still take advantage of a user server-side prop when a user is authenticated.

It would be great to do something along the lines of renaming withAuthRequired to withAuth, and make authRequired a boolean argument – if true, redirect if no user is authed, if false, continue but set user to null.

There are clearly other options re naming the arguments etc.

@thorwebdev
Copy link
Member

That's an interesting idea indeed, we'll discuss, thanks for suggesting!

@thorwebdev thorwebdev added enhancement New feature or request nextjs Next.js specific functionality labels Apr 20, 2022
@dijonmusters
Copy link
Contributor

I think this is a fantastic idea and hit this exact problem in a side project I was working on 💯

@thorwebdev thorwebdev linked a pull request May 10, 2022 that will close this issue
@thorwebdev
Copy link
Member

This is now possible via withPageAuth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request nextjs Next.js specific functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants