Currently, we are using useRequireAuth hook as a way to redirect to login page when a non-logged in user is trying to access authenticated components. But issue is at least 1 request is sent to backend that fails while Frontend already knows the user is not logged in. So This PR is introducing a Higher-Order-Component withAuth that will not render authenticated components except when the user is logged in, otherwise redirects the user to login page.
Summary
Currently, we are using
useRequireAuth
hook as a way to redirect to login page when a non-logged in user is trying to access authenticated components. But issue is at least 1 request is sent to backend that fails while Frontend already knows the user is not logged in. So This PR is introducing a Higher-Order-ComponentwithAuth
that will not render authenticated components except when the user is logged in, otherwise redirects the user to login page.