Skip to content

Commit

Permalink
[INT-705] The verifyKey method is not working for staging environment (
Browse files Browse the repository at this point in the history
…#70)

Fixed: verifyKey aiming to the right environment
  • Loading branch information
YokySantiago authored Jun 22, 2022
1 parent 0d1b9e6 commit 925f8a5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2,842 deletions.
4 changes: 2 additions & 2 deletions lib/onfleet.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ class Onfleet {
}

verifyKey() {
// Utility function to authenticate the API key
return util.authenticate(this.apiKey);
// Utility function to authenticate the API key
return util.authenticate(this.api);
}
}

Expand Down
9 changes: 3 additions & 6 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@ exports.encode = (apiKey) => {
return base64data;
};

exports.authenticate = (apiKey) => {
exports.authenticate = (api) => {
// Authentication checker, returns a boolean
const url = 'https://onfleet.com/api/v2/auth/test';
const url = `${api.baseUrl}/auth/test`;
return fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Basic ${this.encode(apiKey)}`,
},
headers: api.headers,
})
.then((res) => {
if (res.ok) {
Expand Down
Loading

0 comments on commit 925f8a5

Please sign in to comment.