Skip to content

Commit 748d069

Browse files
committed
Implement support for re-authentication params.
1 parent 1e74b7b commit 748d069

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

lib/strategy.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,19 @@ Strategy.prototype.authenticate = function(req, options) {
9090
* @api protected
9191
*/
9292
Strategy.prototype.authorizationParams = function (options) {
93-
var params = {},
94-
display = options.display;
93+
var params = {};
9594

96-
if (display) {
97-
params['display'] = display;
95+
// https://developers.facebook.com/docs/reference/dialogs/oauth/
96+
if (options.display) {
97+
params['display'] = options.display;
98+
}
99+
100+
// https://developers.facebook.com/docs/facebook-login/reauthentication/
101+
if (options.authType) {
102+
params['auth_type'] = options.authType;
103+
}
104+
if (options.authNonce) {
105+
params['auth_nonce'] = options.authNonce;
98106
}
99107

100108
return params;

test/strategy.authorizationparams.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,23 @@ describe('Strategy', function() {
2929
});
3030
});
3131

32+
describe('handling a request to be redirected with reauthorization params', function() {
33+
var url;
34+
35+
before(function(done) {
36+
chai.passport(strategy)
37+
.redirect(function(u) {
38+
url = u;
39+
done();
40+
})
41+
.req(function(req) {
42+
})
43+
.authenticate({ authType: 'reauthenticate', authNonce: 'foo123' });
44+
});
45+
46+
it('should be redirected', function() {
47+
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');
48+
});
49+
});
50+
3251
});

0 commit comments

Comments
 (0)