From a5b3463199225db85db3b23326e3fbd219f9da09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20L=C3=B3pez=20Dato?= Date: Wed, 21 Sep 2016 22:34:51 -0300 Subject: [PATCH] Fix popup mode when no id_token is returned Fixes #205 --- index.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 12d28118..962222db 100644 --- a/index.js +++ b/index.js @@ -969,7 +969,7 @@ Auth0.prototype.loginWithPopup = function(options, callback) { } // Handle profile retrieval from id_token and respond - if (result.id_token) { + if (result.access_token || result.id_token) { return callback(null, _this._prepareResult(result)); } @@ -1926,14 +1926,12 @@ Auth0.prototype._prepareResult = function(result) { return; } - var idTokenPayload = result.profile - ? result.profile - : this.decodeJwt(result.id_token); + var decodedIdToken = result.id_token ? this.decodeJwt(result.id_token) : undefined; return { accessToken: result.access_token, idToken: result.id_token, - idTokenPayload: idTokenPayload, + idTokenPayload: result.profile || decodedIdToken, refreshToken: result.refresh_token, state: result.state };