Skip to content

Commit

Permalink
fix(npm): use parsed body in case response.body is gzip encoded
Browse files Browse the repository at this point in the history
  • Loading branch information
PSanetra authored and pvdlg committed Apr 9, 2018
1 parent 45c00b4 commit d1c6bbc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function getNpmToken({npm, options}) {
} else if (err) {
resolve({err});
} else {
resolve(response.body);
resolve(parsed);
}
});
});
Expand Down Expand Up @@ -72,11 +72,11 @@ async function validateToken(otp, uri, body, npm) {
}

return new Promise(resolve => {
client.request(uri, {method: 'PUT', auth: {otp}, body}, (err, parsed, raw, response) => {
if (err || !response.body.ok) {
client.request(uri, {method: 'PUT', auth: {otp}, body}, (err, parsed) => {
if (err || !parsed || !parsed.ok) {
resolve('Invalid authentication code');
} else {
npm.token = response.body.token;
npm.token = parsed.token;
resolve(true);
}
});
Expand Down

0 comments on commit d1c6bbc

Please sign in to comment.