I need to redirect to auth if a user is not logged...
# support-questions
I need to redirect to auth if a user is not logged in, I can use
to wrap my components but when I try to access a protected route including url search params, only the base of the route is send to the auth page as the redirectToPath and does not include my url search params. I'd prefer not to roll my own wrapper, so is there a way to configure
to include url search params in the redirectToPath? If not, I figure i have to create my own wrapper that checks if the user is logged in. I've tried importing
into my NextJS app,
import SuperTokens from 'supertokens-website'
, however whenever I try to access
i get an error stating that SuperTokens is undefined. I have initialized SuperTokens in the _app.ts file. I can use
but not
hey @mwill8886 can you open an issue about this please? We can add support for this. In the meantime however, you can use
<ThirdPartyEmailPasswordAuth requireAuth={false}>...</ThirdPartyEmailPasswordAuth>
This will allow your child component to render even if the user is not logged in, and in there, you can use the session context to see check if a user is not logged in and then redirect them to wherever you like with the query params intact.
Do you want me to open an issue on the github repo for
on supertokens-auth-react
are you using supertokens-website?
or supertokens-auth-react?
so I tried accessing the context following the steps on here: https://supertokens.com/docs/thirdpartyemailpassword/common-customizations/sessions/checking-session-front-end
returns false even after sign up. We do have our own UI for the signup and login screens following: https://supertokens.com/blog/adding-social-login-to-your-website-with-supertokens I don't know if that's effecting it or not.
disregard last, I implemented it incorrectly at first. I changed it so I wrapped the entire app with
<ThirdPartyEmailPasswordAuth requireAuth={false}>
then checked the context in the individual pages. Now the context comes back correctly.