hide mfa method from selection if phone or email is not verified

This commit is contained in:
peintnermax
2024-05-07 14:27:56 +02:00
parent 92e9150405
commit 09194d18f9
3 changed files with 72 additions and 43 deletions

View File

@@ -11,6 +11,8 @@ type Props = {
loginSettings: LoginSettings;
userMethods: AuthenticationMethodType[];
checkAfter: boolean;
phoneVerified: boolean;
emailVerified: boolean;
};
export default function ChooseSecondFactorToSetup({
@@ -21,6 +23,8 @@ export default function ChooseSecondFactorToSetup({
loginSettings,
userMethods,
checkAfter,
phoneVerified,
emailVerified,
}: Props) {
const params = new URLSearchParams({});
@@ -43,20 +47,15 @@ export default function ChooseSecondFactorToSetup({
return (
<div className="grid grid-cols-1 gap-5 w-full pt-4">
{loginSettings.secondFactors.map((factor, i) => {
return (
<div key={"method-" + i}>
{factor === 1 &&
TOTP(
userMethods.includes(4),
userMethods.includes(4) ? "" : "/otp/time-based/set?" + params
)}
{factor === 2 && U2F(userMethods.includes(5), "/u2f/set?" + params)}
{factor === 3 &&
EMAIL(userMethods.includes(7), "/otp/email/set?" + params)}
{factor === 4 &&
SMS(userMethods.includes(6), "/otp/sms/set?" + params)}
</div>
);
return factor === 1
? TOTP(userMethods.includes(4), "/otp/time-based/set?" + params)
: factor === 2
? U2F(userMethods.includes(5), "/u2f/set?" + params)
: factor === 3 && emailVerified
? EMAIL(userMethods.includes(7), "/otp/email/set?" + params)
: factor === 4 && phoneVerified
? SMS(userMethods.includes(6), "/otp/sms/set?" + params)
: null;
})}
</div>
);