Created
November 12, 2022 04:46
-
-
Save srph/29bea326b3ac358de332f0eb416bec83 to your computer and use it in GitHub Desktop.
auth0-nextjs: Authorize by role
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const getServerSideProps = withPageAuthRequired({ | |
async getServerSideProps(ctx) { | |
const whitelisted = ['[email protected]'] | |
const session = getSession(ctx.req, ctx.res) | |
if (!whitelisted.includes(session.user.email)) { | |
return { | |
redirect: { | |
destination: '/logout', | |
permanent: false, | |
}, | |
props: {}, | |
} | |
} | |
return { props: {} } | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment