Skip to content

Commit

Permalink
fix(strategy.class.ts): routeCredential for anonymous user (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
udaydenduluri33 authored Aug 15, 2023
1 parent 5aa6b7c commit 63b2474
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/auth/models/strategy.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ export abstract class Strategy extends events.EventEmitter {
req.headers['user-roles'] = req.session.passport.user.userinfo.roles.join()
req.headers.Authorization = this.makeAuthorization(req.session.passport)
}
} else if (this.isRouteCredentialNeeded(req.path, this.options)) {
await this.setCredentialToken(req)
}
next()
}
Expand All @@ -341,11 +343,9 @@ export abstract class Strategy extends events.EventEmitter {
let routeCredentialToken
const cachedToken = req.app.get('routeCredentialToken')
if (cachedToken && cachedToken.access_token && !this.isTokenExpired(cachedToken.access_token)) {
this.logger.log('using cached routeCredentialToken')
routeCredentialToken = cachedToken
} else {
routeCredentialToken = await this.generateToken()
this.logger.log('using new routeCredentialToken')
req.app.set('routeCredentialToken', routeCredentialToken)
}
if (routeCredentialToken && routeCredentialToken.access_token) {
Expand Down

0 comments on commit 63b2474

Please sign in to comment.