-
Notifications
You must be signed in to change notification settings - Fork 11
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
Check if user is already authenticated, change sign in form message #61
base: main
Are you sure you want to change the base?
Conversation
web/pages/signin.js
Outdated
</Flex> | ||
); | ||
export async function getServerSideProps({ req }) { | ||
if (req.headers.cookie === null) return { props: { user: null } }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want req.cookies
instead
web/pages/signin.js
Outdated
> | ||
<Heading>Sign In</Heading> | ||
if (user) | ||
return ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we only want one return statement to render a component. We can conditionally render this using the {user && (<content>)}
syntax like we used with the response.
web/pages/signin.js
Outdated
); | ||
export async function getServerSideProps({ req }) { | ||
if (req.headers.cookie === null) return { props: { user: null } }; | ||
const user = await req.user; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this exists and we have access to it, do we even need to check if a cookie exists? Also I don't think req.user would be an async function, so we wouldn't need to await.
Checks if there exists a session cookie, if yes then passes the user as a prop to our sign in functional component