Merge branch 'main' into MED-111
This commit is contained in:
@@ -34,18 +34,20 @@ import {
|
||||
import { Spinner } from '@kit/ui/spinner';
|
||||
import { Trans } from '@kit/ui/trans';
|
||||
|
||||
import pathsConfig from '~/config/paths.config';
|
||||
|
||||
export function MultiFactorChallengeContainer({
|
||||
paths,
|
||||
userId,
|
||||
}: React.PropsWithChildren<{
|
||||
userId: string;
|
||||
paths: {
|
||||
redirectPath: string;
|
||||
};
|
||||
}>) {
|
||||
const router = useRouter();
|
||||
|
||||
const verifyMFAChallenge = useVerifyMFAChallenge({
|
||||
onSuccess: () => {
|
||||
router.replace(pathsConfig.app.home);
|
||||
router.replace(paths.redirectPath);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user