feat(devices): add functionality to delete all authorized devices

This commit is contained in:
shuaiplus
2026-03-08 22:12:01 +08:00
parent 61dac98a12
commit d48e6b6ce5
10 changed files with 230 additions and 41 deletions
+25 -1
View File
@@ -43,6 +43,7 @@ import {
getPreloginKdfConfig,
getProfile,
getAuthorizedDevices,
getCurrentDeviceIdentifier,
getSetupStatus,
getSends,
getTotpStatus,
@@ -60,6 +61,7 @@ import {
saveSession,
setTotp,
setUserStatus,
deleteAllAuthorizedDevices,
deleteAuthorizedDevice,
uploadCipherAttachment,
updateCipher,
@@ -969,10 +971,21 @@ export default function App() {
async function removeDeviceAction(device: AuthorizedDevice) {
await deleteAuthorizedDevice(authedFetch, device.identifier);
if (device.identifier === getCurrentDeviceIdentifier()) {
pushToast('success', t('txt_device_removed'));
logoutNow();
return;
}
await authorizedDevicesQuery.refetch();
pushToast('success', t('txt_device_removed'));
}
async function removeAllDevicesAction() {
await deleteAllAuthorizedDevices(authedFetch);
pushToast('success', t('txt_all_devices_removed'));
logoutNow();
}
async function createVaultItem(draft: VaultDraft, attachments: File[] = []) {
if (!session) return;
try {
@@ -2004,7 +2017,7 @@ export default function App() {
onRemoveDevice={(device) => {
setConfirm({
title: t('txt_remove_device'),
message: t('txt_remove_device_name_and_clear_its_2fa_trust', { name: device.name }),
message: t('txt_remove_device_and_sign_out_name', { name: device.name }),
danger: true,
onConfirm: () => {
setConfirm(null);
@@ -2023,6 +2036,17 @@ export default function App() {
},
});
}}
onRemoveAll={() => {
setConfirm({
title: t('txt_remove_all_devices'),
message: t('txt_remove_all_devices_and_sign_out_all_sessions'),
danger: true,
onConfirm: () => {
setConfirm(null);
void removeAllDevicesAction();
},
});
}}
/>
</div>
</Route>