Skip to content

Commit

Permalink
fix: catch exception when chalege fails and re-enable button
Browse files Browse the repository at this point in the history
  • Loading branch information
ArmanNik committed Sep 9, 2024
1 parent b96b92f commit f2787f2
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 f2787f2

Please sign in to comment.