Let the user confirm the remote wipe (#15774)

Let the user confirm the remote wipe
This commit is contained in:
John Molakvoæ 2019-06-19 19:43:03 +02:00 committed by GitHub
commit 02e350e271
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 16 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -39,6 +39,17 @@
import AuthTokenList from './AuthTokenList'; import AuthTokenList from './AuthTokenList';
import AuthTokenSetupDialogue from './AuthTokenSetupDialogue'; import AuthTokenSetupDialogue from './AuthTokenSetupDialogue';
const confirm = () => {
return new Promise(res => {
OC.dialogs.confirm(
t('core', 'Do you really want to wipe your data from this device?'),
t('core', 'Confirm wipe'),
res,
true
)
})
}
/** /**
* Tap into a promise without losing the value * Tap into a promise without losing the value
*/ */
@ -135,22 +146,24 @@
this.tokens.push(token); this.tokens.push(token);
}) })
}, },
wipeToken(token) { async wipeToken(token) {
console.debug('wiping app token', token); console.debug('wiping app token', token);
confirmPassword() try {
.then(() => Axios.post(this.baseUrl + '/wipe/' + token.id)) await confirmPassword()
.then(tap(() => {
console.debug('app token marked for wipe')
// Update the type if (!(await confirm())) {
// TODO: refactor the server-side code to return the updated token console.debug('wipe aborted by user')
token.type = 2; return;
})) }
.catch(err => { await Axios.post(this.baseUrl + '/wipe/' + token.id)
console.error.bind('could not wipe app token', err); console.debug('app token marked for wipe')
OC.Notification.showTemporary(t('core', 'Error while wiping the device with the token'));
}) token.type = 2;
} catch (err) {
console.error('could not wipe app token', err);
OC.Notification.showTemporary(t('core', 'Error while wiping the device with the token'));
}
} }
} }
} }