Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hgranlund committed Nov 6, 2018
2 parents 3c2e58b + 00429cb commit 24ac5ff
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ export default class KeycloakBearerStrategy extends Strategy {
this.success(null, verifiedToken);
} else if (this.options.passReqToCallback) {
this.log.debug('KeycloakBearerStrategy - Passing req back to callback');
this.userVerify(req, verifiedToken, user, this.success);
this.userVerify(req, verifiedToken, user, this.verified);
} else {
this.log.debug(
'KeycloakBearerStrategy - We did not pass Req back to callback'
);
this.userVerify(verifiedToken, user, this.success);
this.userVerify(verifiedToken, user, this.verified);
}
}
handleErrorFromOnlineVerification(data) {
Expand All @@ -138,6 +138,22 @@ export default class KeycloakBearerStrategy extends Strategy {
}
}

verified(err, user, info) {
if (err)
return this.error(err);

if (!user) {
let msg = 'error: invalid_token';
if (info && typeof info === 'string')
msg += `, error description: ${ info}`;
else if (info)
msg += `, error description: ${ JSON.stringify(info)}`;
return this.failWithLog(msg);
}

return this.success(user, info);
}

authenticate(req) {
const token = this.tokenFromReq(req);
if (!token) return;
Expand Down

0 comments on commit 24ac5ff

Please sign in to comment.