Skip to content

Commit

Permalink
Merge 7fe3968 into 0e2a503
Browse files Browse the repository at this point in the history
  • Loading branch information
rivertam committed Sep 10, 2018
2 parents 0e2a503 + 7fe3968 commit 2a1154e
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions lib/strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CognitoExpress {
}

validate(token, callback) {
this.promise.then(() => {
const p = this.promise.then(() => {
let decodedJwt = jwt.decode(token, { complete: true });

if (!decodedJwt) return callback(`Not a valid JWT token`, null);
Expand All @@ -68,8 +68,25 @@ class CognitoExpress {
iss: this.iss,
maxAge: this.tokenExpiration
};
jwtVerify(params, callback);

if (callback) {
jwtVerify(params, callback);
} else {
return new Promise((resolve, reject) => {
jwtVerify(params, (err, result) => {
if (err) {
reject(err);
} else {
resolve(result);
}
});
});
}
});

if (!callback) {
return p;
}
}
}

Expand Down

0 comments on commit 2a1154e

Please sign in to comment.