10 Replies
thanks in advance
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
something like that
so the user willbe redirected with if not logged
Below your
router.push()
you could add another return statement and return for example a loader, if the user is not logged in.
Besides server rendering the page, this is the only way I knowexport async function getServerSideProps(ctx: GetServerSidePropsContext) {
const session = await getServerAuthSession(ctx);
if (session) {
if (session.user?.role === "ADMIN") {
return {
redirect: {
destination: "/admin",
permanent: false,
},
};
}
if (session.user?.role === "MANAGER") {
return {
redirect: {
destination: "/manager",
permanent: false,
},
};
}
if (session.user?.role === "CASHIER") {
return {
redirect: {
destination: "/cashier",
permanent: false,
},
};
}
}
return {
props: {
session,
},
};
}
i manage to do that with this code above
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Ahhh
This is exactly what I need thanks
but how do i authorization?
sadly it can only be use by jwt strategy
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
i use the db session that comes from ct3a template
and idk really know how to setup the jwt