Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions lib/modules/googlehybrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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;

Expand Down
15 changes: 8 additions & 7 deletions lib/modules/openid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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);
Expand Down