Skip to content

Commit

Permalink
PP-12828 Return 404 on /secure/{tokenId} when token is not found in C…
Browse files Browse the repository at this point in the history
…onnector
  • Loading branch information
DomBelcher committed Oct 15, 2024
1 parent b2ef822 commit 076781e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/controllers/secure.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ exports.new = async function (req, res) {
res.redirect(303, generateRoute(resolveActionName(chargeStatus, 'get'), { chargeId }))
}
} catch (err) {
if (err.message === 'NOT_FOUND') {
logger.info(`Call to /secure/{tokenId} is invalid. Token not found for tokenId [${chargeTokenId}].`, getLoggingFields(req))
return responseRouter.response(req, res, 'NOT_FOUND')
}
if (err.message === 'UNAUTHORISED') {
logger.info('Call to /secure/{tokenId} is Unauthorised. This could be due to the token not existing, ' +
'the frontend state cookie not existing, or the frontend state cookie containing an invalid value.',
Expand Down
3 changes: 3 additions & 0 deletions app/models/charge.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ module.exports = correlationId => {
} catch (err) {
throw new Error('CLIENT_UNAVAILABLE', err)
}
if (response.status === 404) {
throw new Error('NOT_FOUND')
}
if (response.status !== 200) {
throw new Error('UNAUTHORISED')
}
Expand Down

0 comments on commit 076781e

Please sign in to comment.