Skip to content

Commit 7ba5bfd

Browse files
authored
Merge pull request #2344 from appwrite/fix-SER-351-Incorrect-otp-options
2 parents 9060e03 + e22f55a commit 7ba5bfd

File tree

1 file changed

+43
-29
lines changed

1 file changed

+43
-29
lines changed

src/lib/components/mfaChallengeFormList.svelte

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
await createChallenge(AuthenticationFactor.Phone);
7070
} else if (factors.email) {
7171
await createChallenge(AuthenticationFactor.Email);
72+
} else if (factors.totp) {
73+
challengeType = AuthenticationFactor.Totp;
7274
}
7375
}
7476
});
@@ -98,35 +100,47 @@
98100
{#if enabledFactors.length > 1}
99101
<span class="with-separators eyebrow-heading-3">or</span>
100102
<div class="u-flex-vertical u-gap-8">
101-
{#if factors.totp && challengeType !== null && challengeType !== AuthenticationFactor.Totp}
102-
<Button
103-
secondary
104-
fullWidth
105-
{disabled}
106-
on:click={() => createChallenge(AuthenticationFactor.Totp)}>
107-
<Icon icon={IconDeviceMobile} slot="start" size="s" />
108-
Authenticator app
109-
</Button>
110-
{/if}
111-
{#if factors.email && challengeType !== AuthenticationFactor.Email}
112-
<Button
113-
secondary
114-
fullWidth
115-
{disabled}
116-
on:click={() => createChallenge(AuthenticationFactor.Email)}>
117-
<Icon icon={IconMail} slot="start" size="s" />
118-
Email verification
119-
</Button>
120-
{/if}
121-
{#if factors.phone && challengeType !== AuthenticationFactor.Phone}
122-
<Button
123-
secondary
124-
fullWidth
125-
{disabled}
126-
on:click={() => createChallenge(AuthenticationFactor.Phone)}>
127-
<Icon icon={IconChatAlt} slot="start" size="s" />
128-
Phone verification
129-
</Button>
103+
{#if factors.totp}
104+
{#if (challengeType === null || challengeType === AuthenticationFactor.Totp || challengeType === AuthenticationFactor.Recoverycode) && factors.email}
105+
<Button
106+
secondary
107+
fullWidth
108+
{disabled}
109+
on:click={() => createChallenge(AuthenticationFactor.Email)}>
110+
<Icon icon={IconMail} slot="start" size="s" />
111+
Email verification
112+
</Button>
113+
{:else if (challengeType === AuthenticationFactor.Recoverycode && !factors.email) || challengeType === AuthenticationFactor.Email}
114+
<Button
115+
secondary
116+
fullWidth
117+
{disabled}
118+
on:click={() => createChallenge(AuthenticationFactor.Totp)}>
119+
<Icon icon={IconDeviceMobile} slot="start" size="s" />
120+
Authenticator app
121+
</Button>
122+
{/if}
123+
{:else}
124+
{#if factors.email && challengeType !== AuthenticationFactor.Email}
125+
<Button
126+
secondary
127+
fullWidth
128+
{disabled}
129+
on:click={() => createChallenge(AuthenticationFactor.Email)}>
130+
<Icon icon={IconMail} slot="start" size="s" />
131+
Email verification
132+
</Button>
133+
{/if}
134+
{#if factors.phone && challengeType !== AuthenticationFactor.Phone}
135+
<Button
136+
secondary
137+
fullWidth
138+
{disabled}
139+
on:click={() => createChallenge(AuthenticationFactor.Phone)}>
140+
<Icon icon={IconChatAlt} slot="start" size="s" />
141+
Phone verification
142+
</Button>
143+
{/if}
130144
{/if}
131145
{#if factors.recoveryCode && challengeType !== AuthenticationFactor.Recoverycode}
132146
<Button

0 commit comments

Comments
 (0)