separate client init from options init
This commit is contained in:
parent
9a7aa3261f
commit
8961a4e519
|
@ -1159,6 +1159,13 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
, _initClient: function (location/*, opts*/) {
|
||||||
|
var me = this;
|
||||||
|
return OAUTH3.discover(me._clientUri, { client_id: me._clientUri }).then(function (clientDirectives) {
|
||||||
|
me._clientDirectives = clientDirectives;
|
||||||
|
return clientDirectives;
|
||||||
|
});
|
||||||
|
}
|
||||||
, init: function (location/*, opts*/) {
|
, init: function (location/*, opts*/) {
|
||||||
var me = this;
|
var me = this;
|
||||||
var p1 = OAUTH3.PromiseA.resolve();
|
var p1 = OAUTH3.PromiseA.resolve();
|
||||||
|
@ -1168,25 +1175,22 @@
|
||||||
|
|
||||||
if (me._identityProviderUri) {
|
if (me._identityProviderUri) {
|
||||||
// returns directives
|
// returns directives
|
||||||
p1 = OAUTH3.discover(me._identityProviderUri, { client_id: this._clientUri });
|
p1 = me.setIssuer(me._identityProviderUri);
|
||||||
}
|
}
|
||||||
if (me._resourceProviderUri) {
|
if (me._resourceProviderUri) {
|
||||||
// returns directives
|
// returns directives
|
||||||
p2 = OAUTH3.discover(me._resourceProviderUri, { client_id: this._clientUri });
|
p2 = me.setAudience(me._resourceProviderUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
return p1.then(function () {
|
return p1.then(function () {
|
||||||
return p2.then(function () {
|
return p2.then(function () {
|
||||||
return OAUTH3.discover(me._clientUri, { client_id: me._clientUri }).then(function (clientDirectives) {
|
return me._initClient();
|
||||||
me._clientDirectives = clientDirectives;
|
|
||||||
return clientDirectives;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
, setProvider: function (providerUri) {
|
, setProvider: function (providerUri) {
|
||||||
var me = this;
|
var me = this;
|
||||||
return me.init().then(function () {
|
return me._initClient().then(function () {
|
||||||
return me.setIdentityProvider(providerUri).then(function () {
|
return me.setIdentityProvider(providerUri).then(function () {
|
||||||
// TODO how to say "Use xyz.com for org.oauth3.domains, but abc.com for org.oauth3.dns"?
|
// TODO how to say "Use xyz.com for org.oauth3.domains, but abc.com for org.oauth3.dns"?
|
||||||
return me.setResourceProvider(providerUri);
|
return me.setResourceProvider(providerUri);
|
||||||
|
@ -1196,7 +1200,7 @@
|
||||||
, setIdentityProvider: function (providerUri) {
|
, setIdentityProvider: function (providerUri) {
|
||||||
var me = this;
|
var me = this;
|
||||||
me._identityProviderUri = providerUri;
|
me._identityProviderUri = providerUri;
|
||||||
return me.init().then(function () {
|
return me._initClient().then(function () {
|
||||||
// this should be synchronous the second time around
|
// this should be synchronous the second time around
|
||||||
return OAUTH3.discover(me._identityProviderUri, { client_id: me._clientUri }).then(function (directives) {
|
return OAUTH3.discover(me._identityProviderUri, { client_id: me._clientUri }).then(function (directives) {
|
||||||
me._identityProviderDirectives = directives;
|
me._identityProviderDirectives = directives;
|
||||||
|
@ -1207,7 +1211,7 @@
|
||||||
, setResourceProvider: function (providerUri) {
|
, setResourceProvider: function (providerUri) {
|
||||||
var me = this;
|
var me = this;
|
||||||
me._resourceProviderUri = providerUri;
|
me._resourceProviderUri = providerUri;
|
||||||
return me.init().then(function () {
|
return me._initClient().then(function () {
|
||||||
// this should be synchronous the second time around
|
// this should be synchronous the second time around
|
||||||
return OAUTH3.discover(me._resourceProviderUri, { client_id: me._clientUri }).then(function (directives) {
|
return OAUTH3.discover(me._resourceProviderUri, { client_id: me._clientUri }).then(function (directives) {
|
||||||
me._resourceProviderDirectives = directives;
|
me._resourceProviderDirectives = directives;
|
||||||
|
|
Loading…
Reference in New Issue