diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/service/registration.js | 13 | ||||
-rw-r--r-- | js/view/settings.vue | 16 |
2 files changed, 28 insertions, 1 deletions
diff --git a/js/service/registration.js b/js/service/registration.js index a6aa230..dddfc26 100644 --- a/js/service/registration.js +++ b/js/service/registration.js @@ -40,3 +40,16 @@ export function tryVerification(code) { throw resp; }) } + +export function disable() { + let url = OC.generateUrl('/apps/twofactor_sms/settings/verification') + + return nc_fetch_json(url, { + method: 'DELETE' + }).then(function (resp) { + if (resp.ok) { + return resp.json(); + } + throw resp; + }) +} diff --git a/js/view/settings.vue b/js/view/settings.vue index b58f7ee..bdf6973 100644 --- a/js/view/settings.vue +++ b/js/view/settings.vue @@ -17,6 +17,7 @@ </p> <p v-if="state === 2"> <l10n text="SMS-based two-factor authentication is enabled for your account."></l10n> + <button @click="disable"><l10n text="Disable"></l10n></button> </p> </div> </div> @@ -27,7 +28,8 @@ import l10n from "view/l10n.vue"; import { getState, startVerification, - tryVerification + tryVerification, + disable } from "service/registration"; export default { @@ -68,6 +70,18 @@ export default { this.loading = false; }) .catch(console.error.bind(this)); + }, + + disable: function() { + this.loading = true; + + disable() + .then(res => { + this.state = res.state; + this.phoneNumber = res.phoneNumber; + this.loading = false; + }) + .catch(console.error.bind(this)); } }, components: { |