Skip to content

Commit

Permalink
fix: made sure that state failures are emitted to the consuming app (#…
Browse files Browse the repository at this point in the history
…152)

* fix: made sure that state failures are emitted to the consuming app

* fix: state failures fix

* Revert "fix: state failures fix"

This reverts commit b8463bd.

Co-authored-by: ernestman28 <[email protected]>
  • Loading branch information
phillip-whitaker-hmcts and ernestman28 authored Mar 8, 2022
1 parent c697b5a commit 5c2e2d2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/auth/models/strategy.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ export abstract class Strategy extends events.EventEmitter {
}

public callbackHandler = (req: Request, res: Response, next: NextFunction): void => {
const INVALID_STATE_ERROR = 'Invalid authorization request state.'

passport.authenticate(
this.strategyName,
{
Expand All @@ -230,6 +232,11 @@ export abstract class Strategy extends events.EventEmitter {
this.logger.error(error)
}
if (info) {
if (info.message === INVALID_STATE_ERROR) {
res.locals.message = INVALID_STATE_ERROR
this.emit(AUTH.EVENT.AUTHENTICATE_FAILURE, req, res, next)
}

this.logger.info(info)
}
if (!user) {
Expand Down

0 comments on commit 5c2e2d2

Please sign in to comment.