From c5cc2be470b3d974ca59d8550bd1a16e871bb3fe Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 13 Nov 2017 23:14:28 +0000 Subject: [PATCH] opens authorization_dialog --- index.html | 13 +++++++------ js/playground.js | 33 +++++++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/index.html b/index.html index ea23667..5b058ed 100644 --- a/index.html +++ b/index.html @@ -153,18 +153,19 @@

Go ahead, test our login

-
err
+
taking my sweet time to do something in the background...
+
is a valid login provider
- - - + + +
@@ -187,9 +188,9 @@
- Client URI: + Client URI:
- + (this is the URL of the application as per window.location.href)
OAUTH3.clientUri({ host: "" });
diff --git a/js/playground.js b/js/playground.js index 903a129..805ebd9 100644 --- a/js/playground.js +++ b/js/playground.js @@ -77,7 +77,7 @@ vm.form.user = parts.join(''); } else { //vm.form.hasUser = false; - vm.form.user = null; + vm.form.user = ''; provider = parts.join(''); } @@ -86,17 +86,24 @@ } vm.form.userProvider = provider; - vm.fn.debounce('provider', 250).then(function () { + parts = vm.form.provider.split('.'); + return vm.fn.debounce('provider', 250).then(function () { + // Careful: don't use state within a debounce function // uses vm.form.provider for lookup - if (vm.form.provider.length >= 5 && vm.form.provider.split('.').length >= 2) { - vm.api.discover(); + if (parts.length >= 2 && parts[parts.length - 1].length >= 2 && parts.every(function (p) {return p.length})) { + return vm.api.discover(); } }); }; vm.fn.changeProvider = function () { vm.form.providerIndependent = true; + + var parts = vm.form.provider.split('.'); vm.fn.debounce('provider', 250).then(function () { - console.log("[TODO] discover advanced-provider"); + // Careful: don't use state within a debounce function + if (parts.length >= 2 && parts[parts.length - 1].length >= 2 && parts.every(function (p) {return p.length})) { + return vm.api.discover(); + } }); }; vm.fn.toggleAdvanced = function () { @@ -170,7 +177,8 @@ console.log('[DEBUG] directives:'); console.log(dir); vm.validated.provider = provider; - vm.directives = JSON.stringify(dir, null, 2); + vm.directives = dir; + //JSON.stringify(dir, null, 2); }, function (err) { if (latest !== vm.api._discoverCount) { console.warn('[DEBUG] ignoring stale discover error for', provider); @@ -183,6 +191,19 @@ vm.fn.unlock(); }); }; + vm.api.implicitGrant = function () { + var provider = vm.validated.provider; + var opts = { + client_uri: vm.conf.client_uri + , subject: vm.form.user + }; + + vm.implicitGrantObj = OAUTH3.urls.implicitGrant(vm.directives, opts); + console.log('[DEBUG] vm.implicitGrantObj'); + console.log(vm.implicitGrantObj); + vm.implicitGrantUrl = OAUTH3.url.normalize(provider) + '/' + vm.implicitGrantObj.query._pathname; + return OAUTH3.implicitGrant(provider, opts); + }; } ] ); }());