diff --git a/lib/modules/googlehybrid.js b/lib/modules/googlehybrid.js index f05c176b..d131fb23 100644 --- a/lib/modules/googlehybrid.js +++ b/lib/modules/googlehybrid.js @@ -11,19 +11,6 @@ openidModule.submodule('googlehybrid') , consumerSecret: 'Consumer Secret' }) .definit( function () { - this.relyingParty = - new oid.RelyingParty(this._myHostname + this._callbackPath, null, false, false, [ - new oid.AttributeExchange({ - 'http://axschema.org/contact/email': 'required' - , 'http://axschema.org/namePerson/first': 'required' - , 'http://axschema.org/namePerson/last': 'required' - }) - , new oid.OAuthHybrid({ - consumerKey: this._consumerKey - , scope: this._scope.join(' ') - }) - ]); - this.oauth = new OAuth( 'https://www.google.com/accounts/OAuthGetRequestToken' , 'https://www.google.com/accounts/OAuthGetAccessToken' @@ -46,11 +33,27 @@ openidModule.submodule('googlehybrid') return p; }) .sendToAuthenticationUri(function (req, res) { - // Automatic hostname detection + assignment if (!this._myHostname || this._alwaysDetectHostname) { this.myHostname(extractHostname(req)); } + + if(!this.relyingParty){ + this.relyingParty = + new oid.RelyingParty(this.myHostname() + this._callbackPath, null, false, false, [ + new oid.AttributeExchange({ + 'http://axschema.org/contact/email': 'required' + , 'http://axschema.org/namePerson/first': 'required' + , 'http://axschema.org/namePerson/last': 'required' + , "http://axschema.org/media/image/default" : "required" + , "http://axschema.org/x/media/signature" : "required" + }) + , new oid.OAuthHybrid({ + consumerKey: this._consumerKey + , scope: this._scope.join(' ') + }) + ]); + } var self = this; diff --git a/lib/modules/openid.js b/lib/modules/openid.js index 6f083fd8..3be932a2 100644 --- a/lib/modules/openid.js +++ b/lib/modules/openid.js @@ -13,13 +13,6 @@ everyModule.submodule('openid') , redirectPath : 'The path to redirect To' , openidURLField : 'The post field to use for open id' }) - .definit( function () { - this.relyingParty = new oid.RelyingParty(this.myHostname() + this.callbackPath(), null, false, false, [ - new oid.UserInterface() - , new oid.SimpleRegistration(this.simpleRegistration()) - , new oid.AttributeExchange(this.attributeExchange()) - ]); - }) .get('entryPath', 'the link a user follows, whereupon you kick off the OpenId auth process - e.g., "/auth/openid"') .step('sendToAuthenticationUri') @@ -51,6 +44,14 @@ everyModule.submodule('openid') this.myHostname(extractHostname(req)); } + if(!this.relyingParty){ + this.relyingParty = new oid.RelyingParty(this.myHostname() + this.callbackPath(), null, false, false, [ + new oid.UserInterface() + , new oid.SimpleRegistration(this.simpleRegistration()) + , new oid.AttributeExchange(this.attributeExchange()) + ]); + } + this.relyingParty.authenticate(req.query[this.openidURLField()], false, function(err,authenticationUrl){ if(err) return p.fail(err); this.redirect(res, authenticationUrl);