Skip to content

Commit

Permalink
Merge pull request hapijs#273 from garthk/return_artifacts
Browse files Browse the repository at this point in the history
Fixes hapijs#261 expose OAUTH2 token response as request.auth.artifacts
  • Loading branch information
ldesplat authored Mar 24, 2017
2 parents 4426d64 + 89366ac commit 63603c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ exports.v2 = function (settings) {
};

if (!settings.provider.profile || settings.skipProfile) {
return reply.continue({ credentials });
return reply.continue({ credentials, artifacts: payload });
}

// Obtain user profile
Expand Down Expand Up @@ -303,7 +303,7 @@ exports.v2 = function (settings) {

settings.provider.profile.call(settings, credentials, payload, get, () => {

return reply.continue({ credentials });
return reply.continue({ credentials, artifacts: payload });
});
});
};
Expand Down
9 changes: 6 additions & 3 deletions test/providers/auth0.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('auth0', () => {
auth: 'custom',
handler: function (request, reply) {

reply(request.auth.credentials);
reply(request.auth);
}
}
});
Expand All @@ -93,7 +93,7 @@ describe('auth0', () => {
server.inject({ url: mockRes.headers.location, headers: { cookie } }, (response) => {

Mock.clear();
expect(response.result).to.equal({
expect(response.result.credentials).to.equal({
provider: 'custom',
token: '456',
expiresIn: 3600,
Expand All @@ -110,7 +110,10 @@ describe('auth0', () => {
raw: profile
}
});

expect(response.result.artifacts).to.equal({
'access_token': '456',
'expires_in': 3600
});
mock.stop(done);
});
});
Expand Down

0 comments on commit 63603c9

Please sign in to comment.