Skip to content

Commit

Permalink
Merge pull request #1435 from govuk-one-login/bugfix/fix-suspended-wi…
Browse files Browse the repository at this point in the history
…th-password-reset

Bugfix: Do not direct to suspensions screen when password reset intervention also applies
  • Loading branch information
BeckaL authored Mar 6, 2024
2 parents 65a4231 + fb0a69d commit a582849
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/middleware/account-interventions-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export function accountInterventionsMiddleware(
);
} else if (
accountInterventionsResponse.data.temporarilySuspended &&
!accountInterventionsResponse.data.passwordResetRequired &&
handleSuspendedStatus
) {
return res.redirect(
Expand Down
17 changes: 17 additions & 0 deletions test/unit/middleware/account-interventions-middleware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: "[email protected]",
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,
Expand Down

0 comments on commit a582849

Please sign in to comment.