diff --git a/src/middleware/account-interventions-middleware.ts b/src/middleware/account-interventions-middleware.ts index 5543ea5a1..da59104ec 100644 --- a/src/middleware/account-interventions-middleware.ts +++ b/src/middleware/account-interventions-middleware.ts @@ -45,6 +45,7 @@ export function accountInterventionsMiddleware( ); } else if ( accountInterventionsResponse.data.temporarilySuspended && + !accountInterventionsResponse.data.passwordResetRequired && handleSuspendedStatus ) { return res.redirect( diff --git a/test/unit/middleware/account-interventions-middleware.test.ts b/test/unit/middleware/account-interventions-middleware.test.ts index 6f63a6759..a495cddc9 100644 --- a/test/unit/middleware/account-interventions-middleware.test.ts +++ b/test/unit/middleware/account-interventions-middleware.test.ts @@ -136,6 +136,23 @@ describe("accountInterventionsMiddleware", () => { ); }); + it("should not redirect to getNextPathAndUpdateJourney with the journey being UNAVAILABLE_TEMPORARY when passwordResetRequired === true and both password reset and suspension interventions are on", async () => { + const fakeAccountInterventionService: AccountInterventionsInterface = { + accountInterventionStatus: sinon.fake.returns({ + data: { + email: "test@test.com", + passwordResetRequired: true, + blocked: false, + temporarilySuspended: true, + }, + }), + } as unknown as AccountInterventionsInterface; + await callMiddleware(true, false, fakeAccountInterventionService); + expect(res.redirect).to.not.have.been.calledWith( + PATH_NAMES.UNAVAILABLE_TEMPORARY + ); + }); + it("should not redirect to UNAVAILABLE_TEMPORARY when temporarilySuspended === true in the response and supportAccountInterventions() returns true", async () => { const fakeAccountInterventionService = fakeAccountInterventionsService({ passwordResetRequired: false,