feat(MED-85): redirect to dashboard after MFA is done
This commit is contained in:
@@ -47,7 +47,7 @@ export function MultiFactorChallengeContainer({
|
|||||||
|
|
||||||
const verifyMFAChallenge = useVerifyMFAChallenge({
|
const verifyMFAChallenge = useVerifyMFAChallenge({
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
router.replace('/');
|
router.replace(paths.redirectPath);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -114,12 +114,23 @@ export async function middleware(request: NextRequest) {
|
|||||||
|
|
||||||
let cacheId = cacheIdCookie?.value || crypto.randomUUID();
|
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 countryCode = regionMap && (await getCountryCode(request, regionMap));
|
||||||
|
|
||||||
const urlHasCountryCode =
|
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 one of the country codes is in the url and the cache id is set, return next
|
||||||
if (urlHasCountryCode && cacheIdCookie) {
|
if (urlHasCountryCode && cacheIdCookie) {
|
||||||
|
|||||||
Reference in New Issue
Block a user