Generate Token through Auth0
This commit is contained in:
10
front/src/components/RequireAuth.tsx
Normal file
10
front/src/components/RequireAuth.tsx
Normal file
@ -0,0 +1,10 @@
|
||||
import AuthService from '../hooks/AuthenticationHooks';
|
||||
|
||||
function RequireAuth({ children }: { children: JSX.Element }): JSX.Element {
|
||||
const { redirectIfNotLoggedIn } = AuthService;
|
||||
redirectIfNotLoggedIn();
|
||||
|
||||
return children;
|
||||
}
|
||||
|
||||
export default RequireAuth;
|
||||
14
front/src/components/__stories__/RequireAuth.stories.tsx
Normal file
14
front/src/components/__stories__/RequireAuth.stories.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
import RequireAuth from '../RequireAuth';
|
||||
|
||||
import Navbar from '../RequireAuth';
|
||||
|
||||
export default {
|
||||
title: 'RequireAuth',
|
||||
component: Navbar,
|
||||
};
|
||||
|
||||
export const RequireAuthWithHelloChild = () => (
|
||||
<RequireAuth>
|
||||
<div>Hello</div>
|
||||
</RequireAuth>
|
||||
);
|
||||
9
front/src/components/__tests__/RequireAuth.test.tsx
Normal file
9
front/src/components/__tests__/RequireAuth.test.tsx
Normal file
@ -0,0 +1,9 @@
|
||||
import { render } from '@testing-library/react';
|
||||
|
||||
import { RequireAuthWithHelloChild } from '../__stories__/RequireAuth.stories';
|
||||
|
||||
it('Checks the Require Auth renders', () => {
|
||||
const { getAllByText } = render(<RequireAuthWithHelloChild />);
|
||||
|
||||
expect(getAllByText('Hello')).toBeTruthy();
|
||||
});
|
||||
Reference in New Issue
Block a user