Redirect to dynamic url after log in
Hi guys,
Is there any documentation or does anyone have any answers on how I can redirect a user to their dashboard page after logging in? e.g baseUrl/{user.id}'
1 Reply
I tried using the signIn callback
async signIn({ user, account, profile, email, credentials }) {
// Redirect to the dashboard with user ID
const url = "/" + user.id;
return url;
},
its not working because I am validating the session server side when navigating to the dashboard page
export async function getServerSideProps(ctx: GetSessionParams | undefined) {
const session = await getSession(ctx);
if (!session) {
return {
redirect: {
destination: "/",
permanent: false,
},
};
} else {
return {
props: {},
};
}
}
If I remove the getserversideprops function it works as expected. Does anyone have any suggestions how I should be implementing this?