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:
Giancarlo Buomprisco
2025-05-28 08:27:45 +07:00
committed by GitHub
parent 40afecde93
commit cb80e4fdcf
2 changed files with 5 additions and 3 deletions

View File

@@ -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,
};

View File

@@ -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);
}
};