From 79648af88cf8084fe1e9112bc18151f7ef57df00 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 21 Jun 2018 06:23:16 +0000 Subject: [PATCH] check invalid and complete statuses --- lib/extensions/admin/login/js/app.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/extensions/admin/login/js/app.js b/lib/extensions/admin/login/js/app.js index c8ebd32..5655505 100644 --- a/lib/extensions/admin/login/js/app.js +++ b/lib/extensions/admin/login/js/app.js @@ -3,6 +3,7 @@ var meta = {}; var magic; +var domainname; function checkStatus() { // TODO use Location or Link @@ -36,7 +37,24 @@ function submitCode(pair) { , cors: true }).then(function (resp) { return resp.json().then(function (data) { + // TODO check for error (i.e. bad Pair Code / PIN) + // shouldn't be pending (because we get here by being ready) + // should poll over 'ready' + if ('invalid' === data.status) { + window.alert("something went wrong"); + return; + } + if ('complete' === data.status) { + setTimeout(function () { + window.document.body.innerHTML += (''); + // TODO once this is loaded (even error) Let's Encrypt is done, + // then it's time to redirect to the domain. Yay! + }, 1 * 1000); + return; + } + setTimeout(checkStatus, 0); + document.querySelector('.js-authz').hidden = false; console.log(data); /* @@ -45,6 +63,7 @@ function submitCode(pair) { }); */ document.querySelectorAll('.js-new-href').forEach(function ($el) { + domainname = data.domains[0]; $el.href = 'https://' + data.domains[0] + '/'; $el.innerText = '🔐 https://' + data.domains[0]; });