Skip to content

Commit

Permalink
Merge pull request #1339 from appwrite/fix-mfa-catch-exeption
Browse files Browse the repository at this point in the history
fix: catch exception when chalege fails and re-enable button
  • Loading branch information
TorstenDittmann committed Sep 9, 2024
2 parents 3adeecb + f2787f2 commit dc7df61
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/lib/components/mfaChallengeFormList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import { Dependencies } from '$lib/constants';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { AuthenticationFactor, type Models } from '@appwrite.io/console';
import { addNotification } from '$lib/stores/notifications';
export let factors: Models.MfaFactors & { recoveryCode: boolean };
/** If true, the form will be submitted automatically when the code is entered. */
Expand All @@ -40,8 +41,16 @@
async function createChallenge(factor: AuthenticationFactor) {
disabled = true;
challengeType = factor;
challenge = await sdk.forConsole.account.createMfaChallenge(factor);
disabled = false;
try {
challenge = await sdk.forConsole.account.createMfaChallenge(factor);
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
} finally {
disabled = false;
}
}
onMount(async () => {
Expand Down

0 comments on commit dc7df61

Please sign in to comment.