Skip to content

Commit

Permalink
Implement support for re-authentication params.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhanson committed Aug 15, 2013
1 parent 1e74b7b commit 748d069
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,19 @@ Strategy.prototype.authenticate = function(req, options) {
* @api protected
*/
Strategy.prototype.authorizationParams = function (options) {
var params = {},
display = options.display;
var params = {};

if (display) {
params['display'] = display;
// https://developers.facebook.com/docs/reference/dialogs/oauth/
if (options.display) {
params['display'] = options.display;
}

// https://developers.facebook.com/docs/facebook-login/reauthentication/
if (options.authType) {
params['auth_type'] = options.authType;
}
if (options.authNonce) {
params['auth_nonce'] = options.authNonce;
}

return params;
Expand Down
19 changes: 19 additions & 0 deletions test/strategy.authorizationparams.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,23 @@ describe('Strategy', function() {
});
});

describe('handling a request to be redirected with reauthorization params', function() {
var url;

before(function(done) {
chai.passport(strategy)
.redirect(function(u) {
url = u;
done();
})
.req(function(req) {
})
.authenticate({ authType: 'reauthenticate', authNonce: 'foo123' });
});

it('should be redirected', function() {
expect(url).to.equal('https://www.facebook.com/dialog/oauth?auth_type=reauthenticate&auth_nonce=foo123&response_type=code&redirect_uri=&client_id=ABC123&type=web_server');
});
});

});

0 comments on commit 748d069

Please sign in to comment.