Let the user confirm the remote wipe

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
Christoph Wurst 2019-05-28 16:44:41 +02:00
parent b25838e157
commit c77feca64b
No known key found for this signature in database
GPG Key ID: CC42AC2A7F0E56D8
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 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
*/
@ -135,22 +146,24 @@
this.tokens.push(token);
})
},
wipeToken(token) {
async wipeToken(token) {
console.debug('wiping app token', token);
confirmPassword()
.then(() => Axios.post(this.baseUrl + '/wipe/' + token.id))
.then(tap(() => {
try {
await confirmPassword()
if (!(await confirm())) {
console.debug('wipe aborted by user')
return;
}
await Axios.post(this.baseUrl + '/wipe/' + token.id)
console.debug('app token marked for wipe')
// Update the type
// TODO: refactor the server-side code to return the updated token
token.type = 2;
}))
.catch(err => {
console.error.bind('could not wipe app token', err);
} catch (err) {
console.error('could not wipe app token', err);
OC.Notification.showTemporary(t('core', 'Error while wiping the device with the token'));
})
}
}
}
}