Replies: 1 comment 4 replies
-
Hi @marcmll, I'm not an expert in this area but I'm attempting to do a similar thing and thought I'd try to help. Here is what I found... first, I don't think |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey there,
I am currently trying to verify if a user is logged in before a page is loaded, and was wondering if there is a best practice for achieving this. As of now I am trying to verify if a user is logged in within the
getServerSideProps
as follows:This way, in case the user is logged in, I can get the relevant user data before the page loads directly from the database.
Using my current method, I encounter the following error whenever a session is not found:
refering to the
req.session.grant.response.profile.identity.id
line which comes after the redirect should have already occured.When trying to avoid this error by calling
return res.redirect('/auth')
, I receive a different error:which seems to refer to the
getServerSideProps
function expecting theprops
Object as a return.What would be the best way of going about the verification of a users logged in state, without having a page flash and still having a secure way of receiving the users data in case the required session is present.
Also, is this even a smart way of going about the retrieval of user data, or should this happen within the custom server?
Beta Was this translation helpful? Give feedback.
All reactions