Sign in fails when the next parameter is empty (#261)
* Refactor sign-in flow to ensure fallback return paths Updated logic to use fallback values for `returnPath` to prevent potential undefined behavior. Improved consistency in handling default paths during sign-in and redirection processes.
This commit is contained in:
committed by
GitHub
parent
40afecde93
commit
cb80e4fdcf
@@ -26,7 +26,7 @@ export const generateMetadata = async () => {
|
||||
};
|
||||
|
||||
async function SignInPage({ searchParams }: SignInPageProps) {
|
||||
const { invite_token: inviteToken, next = '' } = await searchParams;
|
||||
const { invite_token: inviteToken, next } = await searchParams;
|
||||
|
||||
const signUpPath =
|
||||
pathsConfig.auth.signUp +
|
||||
@@ -34,7 +34,7 @@ async function SignInPage({ searchParams }: SignInPageProps) {
|
||||
|
||||
const paths = {
|
||||
callback: pathsConfig.auth.callback,
|
||||
returnPath: next ?? pathsConfig.app.home,
|
||||
returnPath: next || pathsConfig.app.home,
|
||||
joinTeam: pathsConfig.app.joinTeam,
|
||||
};
|
||||
|
||||
|
||||
@@ -45,8 +45,10 @@ export function SignInMethodsContainer(props: {
|
||||
|
||||
router.replace(joinTeamPath);
|
||||
} else {
|
||||
const returnPath = props.paths.returnPath || '/home';
|
||||
|
||||
// otherwise, we should redirect to the return path
|
||||
router.replace(props.paths.returnPath);
|
||||
router.replace(returnPath);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user