From 7650d5e083571d20d2f73e59dc1fb5c7e36d61cf Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Mon, 25 Jun 2018 15:39:42 +0200 Subject: Let the user specify their identifier/phone number Signed-off-by: Christoph Wurst --- js/service/registration.js | 93 ++++++++++---------- js/view/settings.vue | 212 +++++++++++++++++++++++++-------------------- 2 files changed, 168 insertions(+), 137 deletions(-) (limited to 'js') diff --git a/js/service/registration.js b/js/service/registration.js index fb741fb..2b45fd7 100644 --- a/js/service/registration.js +++ b/js/service/registration.js @@ -1,55 +1,58 @@ import $ from 'jquery'; -import { nc_fetch_json } from 'nextcloud_fetch'; +import {nc_fetch_json} from 'nextcloud_fetch'; -export function getState() { - let url = OC.generateUrl('/apps/twofactor_gateway/settings/verification') +export function getState () { + let url = OC.generateUrl('/apps/twofactor_gateway/settings/verification') - return nc_fetch_json(url).then(function (resp) { - if (resp.ok) { - return resp.json(); - } - throw resp; - }) + return nc_fetch_json(url).then(function (resp) { + if (resp.ok) { + return resp.json(); + } + throw resp; + }) } -export function startVerification() { - let url = OC.generateUrl('/apps/twofactor_gateway/settings/verification/start') - - return nc_fetch_json(url, { - method: 'POST' - }).then(function (resp) { - if (resp.ok) { - return resp.json(); - } - throw resp; - }) +export function startVerification (identifier) { + let url = OC.generateUrl('/apps/twofactor_gateway/settings/verification/start') + + return nc_fetch_json(url, { + method: 'POST', + body: JSON.stringify({ + identifier: identifier + }) + }).then(function (resp) { + if (resp.ok) { + return resp.json(); + } + throw resp; + }) } -export function tryVerification(code) { - let url = OC.generateUrl('/apps/twofactor_gateway/settings/verification/finish') - - return nc_fetch_json(url, { - method: 'POST', - body: JSON.stringify({ - verificationCode: code - }) - }).then(function (resp) { - if (resp.ok) { - return resp.json(); - } - throw resp; - }) +export function tryVerification (code) { + let url = OC.generateUrl('/apps/twofactor_gateway/settings/verification/finish') + + return nc_fetch_json(url, { + method: 'POST', + body: JSON.stringify({ + verificationCode: code + }) + }).then(function (resp) { + if (resp.ok) { + return resp.json(); + } + throw resp; + }) } -export function disable() { - let url = OC.generateUrl('/apps/twofactor_gateway/settings/verification') - - return nc_fetch_json(url, { - method: 'DELETE' - }).then(function (resp) { - if (resp.ok) { - return resp.json(); - } - throw resp; - }) +export function disable () { + let url = OC.generateUrl('/apps/twofactor_gateway/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 ee63145..adeff27 100644 --- a/js/view/settings.vue +++ b/js/view/settings.vue @@ -1,104 +1,132 @@ -- cgit v1.2.3