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

Added withCSRAuthRequired HOC [SDK-2120] #209

Merged
merged 8 commits into from
Dec 21, 2020

Conversation

Widcket
Copy link
Contributor

@Widcket Widcket commented Dec 21, 2020

Description

This PR adds the withCSRAuthRequired higher-order component that allows to protect client-side rendered pages, with unit tests.

Example usage

import { useUser, withCSRAuthRequired } from '@auth0/nextjs-auth0';

export default withCSRAuthRequired(function Profile() {
  const { user, loading } = useUser();

  return (
    // the page
  );
});

Other changes

  • The withPageAuthRequired was renamed to withSSRAuthRequired as I could not find a clean way to have both methods (for SSR and CSR pages) share the same name.
  • The hooks folder was renamed to frontend, as it contains the frontend-only code (the useUser hook and the withCSRAuthRequired HOC).
  • In use-user.tsx the usage of null was replaced with undefined.
  • Some outdated dependencies were updated.

References

Closes #189.

Testing

  • This change adds test coverage for new/changed/fixed functionality

Checklist

  • I have added documentation for new/changed functionality in this PR or in auth0.com/docs
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not master

@Widcket Widcket added the review:large Large review label Dec 21, 2020
@Widcket Widcket requested a review from a team as a code owner December 21, 2020 06:21
@adamjmcgrath
Copy link
Contributor

lgtm, just spotted a typo

The withPageAuthRequired was renamed to withSSRAuthRequired as I could not find a clean way to have both methods (for SSR and CSR pages) share the same name.

Will investigate this separately

@adamjmcgrath adamjmcgrath merged commit c0a1b0a into beta Dec 21, 2020
@adamjmcgrath adamjmcgrath deleted the feature/with-auth-required branch December 21, 2020 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review:large Large review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants