accept providerUri and session on create
This commit is contained in:
parent
f37d47b0d4
commit
4bdacf9770
|
@ -1065,7 +1065,7 @@
|
||||||
|
|
||||||
// this is not necessary, but it's relatively small
|
// this is not necessary, but it's relatively small
|
||||||
// and gives people the 3-line examples they love so much
|
// and gives people the 3-line examples they love so much
|
||||||
OAUTH3.create = function (location/*, opts*/) {
|
OAUTH3.create = function (location, opts) {
|
||||||
if (!location) {
|
if (!location) {
|
||||||
location = OAUTH3._browser.window.location;
|
location = OAUTH3._browser.window.location;
|
||||||
}
|
}
|
||||||
|
@ -1073,16 +1073,29 @@
|
||||||
var result = {
|
var result = {
|
||||||
_clientUri: OAUTH3.clientUri(location)
|
_clientUri: OAUTH3.clientUri(location)
|
||||||
, _providerUri: null
|
, _providerUri: null
|
||||||
, init: function (location) {
|
, _init: function (location, opts) {
|
||||||
|
var me = this;
|
||||||
|
if (location) {
|
||||||
|
me._clientUri = OAUTH3.clientUri(location);
|
||||||
|
}
|
||||||
|
if (opts) {
|
||||||
|
if (opts.providerUri) {
|
||||||
|
me._providerUri = opts.providerUri;
|
||||||
|
}
|
||||||
|
if (opts.session) {
|
||||||
|
me.session(opts.session, opts.sessionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
, init: function (location/*, opts*/) {
|
||||||
var me = this;
|
var me = this;
|
||||||
var p = OAUTH3.PromiseA.resolve();
|
var p = OAUTH3.PromiseA.resolve();
|
||||||
|
|
||||||
if (location) {
|
me._init(location, opts);
|
||||||
this._clientUri = OAUTH3.clientUri(location);
|
|
||||||
}
|
if (me._providerUri) {
|
||||||
if (this._providerUri) {
|
|
||||||
// returns directives
|
// returns directives
|
||||||
p = OAUTH3.discover(this._providerUri, { client_id: this._clientUri });
|
p = OAUTH3.discover(me._providerUri, { client_id: this._clientUri });
|
||||||
}
|
}
|
||||||
|
|
||||||
return p.then(function () {
|
return p.then(function () {
|
||||||
|
@ -1158,6 +1171,9 @@
|
||||||
result.authenticate = result.login;
|
result.authenticate = result.login;
|
||||||
result.authorize = result.login;
|
result.authorize = result.login;
|
||||||
result.expire = result.logout;
|
result.expire = result.logout;
|
||||||
|
|
||||||
|
result._init(location, opts);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue