Skip to content

Commit

Permalink
Merge pull request #17 from electricimp/develop
Browse files Browse the repository at this point in the history
v1.3.0
  • Loading branch information
Pavel Petroshenko authored Aug 3, 2018
2 parents 1031393 + fb98aba commit bb86a65
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 109 deletions.
8 changes: 5 additions & 3 deletions lib/Auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,12 @@ class Auth {
return Promise.reject(error);
}
const body = {
login_token : loginToken,
password : otp
login_token : loginToken
};
return HttpHelper.auth('/auth', body);
const additionalHeaders = {
'X-Electricimp-OTP-Token' : otp
};
return HttpHelper.auth('/auth', body, additionalHeaders);
}

// Retrieves a set of currently active Refresh Tokens for logged-in account.
Expand Down
5 changes: 4 additions & 1 deletion lib/util/HttpHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,13 @@ class HttpHelper {
return HttpHelper._request(method, path, headers, query, body);
}

static auth(path, body) {
static auth(path, body, additionalHeaders = null) {
const headers = {
'Content-type' : 'application/json'
};
if (additionalHeaders) {
Object.assign(headers, additionalHeaders);
}
return HttpHelper._request('POST', path, headers, null, body, true);
}

Expand Down
134 changes: 30 additions & 104 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "imp-central-api",
"version": "1.2.0",
"version": "1.3.0",
"description": "Electric Imp impCentral API v5 Client",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit bb86a65

Please sign in to comment.