Skip to content

Commit

Permalink
Add clarifying comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhanson committed Jul 1, 2021
1 parent 214df32 commit ed71e6b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,14 @@ OAuth2Strategy.prototype.authenticate = function(req, options) {
if (state && typeof state !== 'object') {
// NOTE: In passport-oauth2@1.5.0 and earlier, `state` could be passed as
// an object. However, it would result in an empty string being
// serialized as the value of the query parameter by `url.format()`.
// In practice, this implies that `state` was only functional when
// passed string values.
// serialized as the value of the query parameter by `url.format()`,
// effectively ignoring the option. This implies that `state` was
// only functional when passed as a string value.
//
// This fact is taken advantage of here to fall into the `else`
// branch below when `state` is passed as an object. In that case
// the state will be automatically managed and persisted by the
// state store.
params.state = state;

var parsed = url.parse(this._oauth2._authorizeUrl, true);
Expand Down

0 comments on commit ed71e6b

Please sign in to comment.