feat(MED-85): redirect to dashboard after MFA is done

This commit is contained in:
2025-07-31 12:00:34 +03:00
parent c91adc7521
commit 23a07658c9
2 changed files with 14 additions and 3 deletions

View File

@@ -47,7 +47,7 @@ export function MultiFactorChallengeContainer({
const verifyMFAChallenge = useVerifyMFAChallenge({
onSuccess: () => {
router.replace('/');
router.replace(paths.redirectPath);
},
});

View File

@@ -114,12 +114,23 @@ export async function middleware(request: NextRequest) {
let cacheId = cacheIdCookie?.value || crypto.randomUUID();
const regionMap = await getRegionMap(cacheId);
let regionMap;
try {
regionMap = await getRegionMap(cacheId);
} catch (error) {
console.error("Error fetching regions", error);
return {
redirect: {
destination: '/auth/sign-in',
permanent: false,
},
};
}
const countryCode = regionMap && (await getCountryCode(request, regionMap));
const urlHasCountryCode =
countryCode && request.nextUrl.pathname.split("/")[1].includes(countryCode);
countryCode && request.nextUrl.pathname.split("/")[1]?.includes(countryCode);
// if one of the country codes is in the url and the cache id is set, return next
if (urlHasCountryCode && cacheIdCookie) {