mirror of
https://github.com/documenso/documenso.git
synced 2025-11-16 09:41:35 +10:00
chore: use token input on enable 2fa
This commit is contained in:
@ -130,6 +130,10 @@ export const EnableAuthenticatorAppDialog = ({
|
|||||||
|
|
||||||
return enabled2fa;
|
return enabled2fa;
|
||||||
} catch (_err) {
|
} catch (_err) {
|
||||||
|
enableTwoFactorAuthenticationForm.setError('token', {
|
||||||
|
message: 'Unable to setup two-factor authentication',
|
||||||
|
});
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
title: 'Unable to setup two-factor authentication',
|
title: 'Unable to setup two-factor authentication',
|
||||||
description:
|
description:
|
||||||
@ -251,40 +255,41 @@ export const EnableAuthenticatorAppDialog = ({
|
|||||||
<PinInput
|
<PinInput
|
||||||
id="enable-2fa-pin-input"
|
id="enable-2fa-pin-input"
|
||||||
state={state}
|
state={state}
|
||||||
onSubmit={({ code, input }) => {
|
onSubmit={async ({ code, input }) => {
|
||||||
console.log(code);
|
|
||||||
|
|
||||||
if (code.length === 6) {
|
if (code.length === 6) {
|
||||||
setState('loading');
|
setState('loading');
|
||||||
|
enableTwoFactorAuthenticationForm.setValue('token', code);
|
||||||
|
|
||||||
void onEnableTwoFactorAuthenticationFormSubmit({ token: code }).then(
|
await enableTwoFactorAuthenticationForm.handleSubmit(
|
||||||
(success) => {
|
onEnableTwoFactorAuthenticationFormSubmit,
|
||||||
if (success) {
|
)();
|
||||||
setState('success');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setState('error');
|
if (
|
||||||
|
enableTwoFactorAuthenticationForm.formState.isSubmitted &&
|
||||||
|
!enableTwoFactorAuthenticationForm.formState.errors.totpCode
|
||||||
|
) {
|
||||||
|
setState('success');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setState('error');
|
||||||
setState('input');
|
|
||||||
input.value = '';
|
setTimeout(() => {
|
||||||
input.dispatchEvent(new Event('input'));
|
setState('input');
|
||||||
input.focus();
|
input.value = '';
|
||||||
}, 500);
|
input.dispatchEvent(new Event('input'));
|
||||||
},
|
input.focus();
|
||||||
);
|
}, 500);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
autoFocus
|
autoFocus
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* <DialogFooter>
|
<DialogFooter>
|
||||||
<Button type="button" variant="secondary" onClick={() => onOpenChange(false)}>
|
<Button type="button" variant="secondary" onClick={() => onOpenChange(false)}>
|
||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
@ -292,7 +297,7 @@ export const EnableAuthenticatorAppDialog = ({
|
|||||||
<Button type="submit" loading={isEnableTwoFactorAuthenticationSubmitting}>
|
<Button type="submit" loading={isEnableTwoFactorAuthenticationSubmitting}>
|
||||||
Enable 2FA
|
Enable 2FA
|
||||||
</Button>
|
</Button>
|
||||||
</DialogFooter> */}
|
</DialogFooter>
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
))
|
))
|
||||||
|
|||||||
Reference in New Issue
Block a user