Skip to content

Commit 12354c1

Browse files
committed
Add metadata when storing state.
1 parent 32b1ecf commit 12354c1

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

lib/strategy.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ OAuth2Strategy.prototype.authenticate = function(req, options) {
141141
callbackURL = url.resolve(utils.originalURL(req, { proxy: this._trustProxy }), callbackURL);
142142
}
143143
}
144+
145+
var meta = {
146+
authorizationURL: this._oauth2._authorizeUrl,
147+
tokenURL: this._oauth2._accessTokenUrl,
148+
clientID: this._oauth2._clientId
149+
}
144150

145151
if (req.query && req.query.code) {
146152
var state = req.query.state;
@@ -208,13 +214,26 @@ OAuth2Strategy.prototype.authenticate = function(req, options) {
208214
var location = this._oauth2.getAuthorizeUrl(params);
209215
this.redirect(location);
210216
} else {
211-
this._stateStore.store(req, function(err, state) {
217+
function stored(err, state) {
212218
if (err) { return self.error(err); }
213219

214220
if (state) { params.state = state; }
215221
var location = self._oauth2.getAuthorizeUrl(params);
216222
self.redirect(location);
217-
});
223+
}
224+
225+
try {
226+
var arity = this._stateStore.store.length;
227+
if (arity == 3) {
228+
this._stateStore.store(req, meta, stored);
229+
} else { // arity == 2
230+
this._stateStore.store(req, stored);
231+
}
232+
233+
234+
} catch (ex) {
235+
return this.error(ex);
236+
}
218237
}
219238
}
220239
};

0 commit comments

Comments
 (0)