Implement redirect control in multi-factor auth container

The update adds a rerouting functionality upon successful multi-factor authentication, replacing a console log action previously triggered upon success. The change enhances the authentication flow by redirecting users to a specified path upon validation. Additionally, minor refactorings are done such as replacing direct routing paths with path configs and adjusting import statements.
This commit is contained in:
giancarlo
2024-03-27 14:30:23 +08:00
parent 2acd9c7d10
commit f0883c19ef
5 changed files with 34 additions and 17 deletions

View File

@@ -8,6 +8,12 @@ import pathsConfig from '~/config/paths.config';
import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
import { withI18n } from '~/lib/i18n/with-i18n';
interface Props {
searchParams: {
next?: string;
};
}
export const generateMetadata = async () => {
const i18n = await createI18nServerInstance();
@@ -16,7 +22,7 @@ export const generateMetadata = async () => {
};
};
async function VerifyPage() {
async function VerifyPage(props: Props) {
const client = getSupabaseServerComponentClient();
const needsMfa = await checkRequiresMultiFactorAuthentication(client);
@@ -24,10 +30,12 @@ async function VerifyPage() {
redirect(pathsConfig.auth.signIn);
}
const redirectPath = props.searchParams.next ?? pathsConfig.app.home;
return (
<MultiFactorChallengeContainer
onSuccess={() => {
console.log('2');
paths={{
redirectPath,
}}
/>
);