Skip to content

Commit

Permalink
reauth fix (Cannot read property 'apply' of undefined error)
Browse files Browse the repository at this point in the history
  • Loading branch information
Frigyes Bartha committed Jun 30, 2020
1 parent 6a6c422 commit 1e4b357
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions carelink.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function reqOptions(extra) {
var defaults = {
jar: true,
followRedirect: false,
rejectUnauthorized: false,
headers: {
Host: carelinkServerAddress,
Connection: 'keep-alive',
Expand Down Expand Up @@ -148,7 +149,6 @@ var Client = exports.Client = function (options) {
CARELINKEU_LOGIN1_URL,
reqOptions({
jar: jar,
rejectUnauthorized: false,
}),
checkResponseThen(next)
);
Expand All @@ -163,7 +163,6 @@ var Client = exports.Client = function (options) {
url,
reqOptions({
jar: jar,
rejectUnauthorized: false,
}),
checkResponseThen(next)
);
Expand All @@ -178,7 +177,6 @@ var Client = exports.Client = function (options) {
CARELINKEU_LOGIN3_URL,
reqOptions({
jar: jar,
rejectUnauthorized: false,
changeOrigin: true,
gzip: true,
form: {
Expand Down Expand Up @@ -207,7 +205,6 @@ var Client = exports.Client = function (options) {
CARELINKEU_LOGIN4_URL,
reqOptions({
jar: jar,
rejectUnauthorized: false,
changeOrigin: true,
form: {
action: "consent",
Expand All @@ -230,7 +227,6 @@ var Client = exports.Client = function (options) {
url,
reqOptions({
jar: jar,
rejectUnauthorized: false,
changeOrigin: true,
}),
checkResponseThen(next)
Expand All @@ -244,7 +240,6 @@ var Client = exports.Client = function (options) {
CARELINKEU_REFRESH_TOKEN_URL,
reqOptions({
jar: jar,
rejectUnauthorized: false,
changeOrigin: true,
gzip: true,
json: true,
Expand Down Expand Up @@ -308,9 +303,9 @@ var Client = exports.Client = function (options) {
let expire = new Date(Date.parse( _.get(getCookie(CARELINKEU_TOKENEXPIRE_COOKIE), 'value', '1970-01-01')));

if (expire < new Date(Date.now() - 5 * 1000 * 60)) {
refreshTokenEu(next);
refreshTokenEu(null, next);
} else {
next(null);
next(null, null);
}
} else {
common.step([
Expand All @@ -319,7 +314,7 @@ var Client = exports.Client = function (options) {
doLoginEu3,
doLoginEu4,
doLoginEu5,
next.bind(null, null)
next.bind(null, null),
],
);
}
Expand Down

0 comments on commit 1e4b357

Please sign in to comment.