mirror of
https://github.com/inventree/InvenTree.git
synced 2025-11-13 19:36:46 +00:00
refactor (frontend): reduce message and time in recovery codes (#10778)
* reduce showing of wrong info boxes * stop waiting 30 sec when there is an error
This commit is contained in:
@@ -29,7 +29,7 @@ import {
|
|||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { useShallow } from 'zustand/react/shallow';
|
import { useShallow } from 'zustand/react/shallow';
|
||||||
import { api } from '../../../../App';
|
import { api, queryClient } from '../../../../App';
|
||||||
import { CopyButton } from '../../../../components/buttons/CopyButton';
|
import { CopyButton } from '../../../../components/buttons/CopyButton';
|
||||||
import { StylishText } from '../../../../components/items/StylishText';
|
import { StylishText } from '../../../../components/items/StylishText';
|
||||||
import { authApi } from '../../../../functions/auth';
|
import { authApi } from '../../../../functions/auth';
|
||||||
@@ -603,6 +603,8 @@ function RecoveryCodesModal({
|
|||||||
setOpen(false);
|
setOpen(false);
|
||||||
onReauthFlow(flow);
|
onReauthFlow(flow);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
queryClient.cancelQueries({ queryKey: ['mfa-recovery-codes'] });
|
||||||
}
|
}
|
||||||
|
|
||||||
throw error;
|
throw error;
|
||||||
@@ -638,7 +640,7 @@ function RecoveryCodesModal({
|
|||||||
)}
|
)}
|
||||||
{recoveryCodesQuery.isFetching || recoveryCodesQuery.isLoading ? (
|
{recoveryCodesQuery.isFetching || recoveryCodesQuery.isLoading ? (
|
||||||
<Loader />
|
<Loader />
|
||||||
) : (
|
) : unusedCodes.length > 0 ? (
|
||||||
<Stack gap='xs'>
|
<Stack gap='xs'>
|
||||||
<Alert
|
<Alert
|
||||||
color='blue'
|
color='blue'
|
||||||
@@ -651,25 +653,15 @@ function RecoveryCodesModal({
|
|||||||
</Alert>
|
</Alert>
|
||||||
<Paper p='sm' withBorder>
|
<Paper p='sm' withBorder>
|
||||||
<Stack gap='xs'>
|
<Stack gap='xs'>
|
||||||
{unusedCodes.length > 0 ? (
|
{unusedCodes.map((code: string) => (
|
||||||
unusedCodes.map((code: string) => (
|
<Group
|
||||||
<Group
|
p={3}
|
||||||
p={3}
|
justify='space-between'
|
||||||
justify='space-between'
|
key={`mfa-recovery-code-${code}`}
|
||||||
key={`mfa-recovery-code-${code}`}
|
|
||||||
>
|
|
||||||
<Text>{code}</Text>
|
|
||||||
</Group>
|
|
||||||
))
|
|
||||||
) : (
|
|
||||||
<Alert
|
|
||||||
color='yellow'
|
|
||||||
icon={<IconAlertCircle />}
|
|
||||||
title={t`No Unused Codes`}
|
|
||||||
>
|
>
|
||||||
<Trans>There are no available recovery codes</Trans>
|
<Text>{code}</Text>
|
||||||
</Alert>
|
</Group>
|
||||||
)}
|
))}
|
||||||
<Divider />
|
<Divider />
|
||||||
<Group justify='space-between'>
|
<Group justify='space-between'>
|
||||||
<Trans>Copy recovery codes to clipboard</Trans>
|
<Trans>Copy recovery codes to clipboard</Trans>
|
||||||
@@ -678,6 +670,14 @@ function RecoveryCodesModal({
|
|||||||
</Stack>
|
</Stack>
|
||||||
</Paper>
|
</Paper>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
) : (
|
||||||
|
<Alert
|
||||||
|
color='yellow'
|
||||||
|
icon={<IconAlertCircle />}
|
||||||
|
title={t`No Unused Codes`}
|
||||||
|
>
|
||||||
|
<Trans>There are no available recovery codes</Trans>
|
||||||
|
</Alert>
|
||||||
)}
|
)}
|
||||||
<Divider />
|
<Divider />
|
||||||
<Group justify='right'>
|
<Group justify='right'>
|
||||||
|
|||||||
Reference in New Issue
Block a user