feat: Add MFA verification for Super Admin users in middleware
This commit is contained in:
@@ -150,20 +150,25 @@ function getPatterns() {
|
|||||||
return NextResponse.redirect(new URL('/', req.nextUrl.origin).href);
|
return NextResponse.redirect(new URL('/', req.nextUrl.origin).href);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const client = createMiddlewareClient(req, res);
|
||||||
|
const userIsSuperAdmin = await isSuperAdmin(client);
|
||||||
|
|
||||||
|
if (userIsSuperAdmin) {
|
||||||
// check if we need to verify MFA (user is authenticated but needs to verify MFA)
|
// check if we need to verify MFA (user is authenticated but needs to verify MFA)
|
||||||
// TODO: this mfa should only be applied to SUPER_ADMIN
|
const isVerifyMfa =
|
||||||
// const isVerifyMfa = req.nextUrl.pathname === pathsConfig.auth.verifyMfa;
|
req.nextUrl.pathname === pathsConfig.auth.verifyMfa;
|
||||||
|
|
||||||
// If user is logged in and does not need to verify MFA,
|
// If user is logged in and does not need to verify MFA,
|
||||||
// redirect to home page.
|
// redirect to home page.
|
||||||
// if (!isVerifyMfa) {
|
if (!isVerifyMfa) {
|
||||||
// const nextPath =
|
const nextPath =
|
||||||
// req.nextUrl.searchParams.get('next') ?? pathsConfig.app.home;
|
req.nextUrl.searchParams.get('next') ?? pathsConfig.app.home;
|
||||||
|
|
||||||
// return NextResponse.redirect(
|
return NextResponse.redirect(
|
||||||
// new URL(nextPath, req.nextUrl.origin).href,
|
new URL(nextPath, req.nextUrl.origin).href,
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user