diff --git a/frontend/components/settings/account/ViewRecoveryDialog.tsx b/frontend/components/settings/account/ViewRecoveryDialog.tsx index 110a8bcd1..9d901f3f9 100644 --- a/frontend/components/settings/account/ViewRecoveryDialog.tsx +++ b/frontend/components/settings/account/ViewRecoveryDialog.tsx @@ -19,14 +19,27 @@ export const ViewRecoveryDialog = () => { const [password, setPassword] = useState('') const [showPw, setShowPw] = useState(false) const [recovery, setRecovery] = useState('') + const [isUnlocking, setIsUnlocking] = useState(false) const handleDecryptRecovery = async (event: { preventDefault: () => void }) => { event.preventDefault() - - const deviceKey = await deviceVaultKey(password, session?.user?.email!) - - const decryptedRecovery = await decryptAccountRecovery(activeOrganisation?.recovery!, deviceKey) - setRecovery(decryptedRecovery) + setIsUnlocking(true) + + try { + // Add small delay to ensure loading state is visible for UX reasons + await new Promise(resolve => setTimeout(resolve, 100)) + + const deviceKey = await deviceVaultKey(password, session?.user?.email!) + + const decryptedRecovery = await decryptAccountRecovery(activeOrganisation?.recovery!, deviceKey) + setRecovery(decryptedRecovery) + } catch (error) { + toast.error("Invalid sudo password. Please check your password and try again.", { + autoClose: 2000, + }) + } finally { + setIsUnlocking(false) + } } const reset = () => { @@ -82,7 +95,7 @@ export const ViewRecoveryDialog = () => {
@@ -170,7 +183,7 @@ export const ViewRecoveryDialog = () => {
-