Skip to content

Commit

Permalink
Merge pull request #1471 from govuk-one-login/BAU/remove-unused-code
Browse files Browse the repository at this point in the history
BAU: Remove unused code from prove-identity-welcome
  • Loading branch information
ethanmills authored Mar 26, 2024
2 parents 9a27dd4 + afdbe62 commit 98a6fb4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Request, Response } from "express";
import { getNextPathAndUpdateJourney } from "../common/constants";
import { USER_JOURNEY_EVENTS } from "../common/state-machine/state-machine";
import { IPV_ERROR_CODES, OIDC_ERRORS, PATH_NAMES } from "../../app.constants";
import { createServiceRedirectErrorUrl } from "../../utils/error";
import { PATH_NAMES } from "../../app.constants";
import { supportLanguageCY } from "../../config";

export function proveIdentityWelcomeGet(req: Request, res: Response): void {
Expand All @@ -11,31 +10,12 @@ export function proveIdentityWelcomeGet(req: Request, res: Response): void {
? "prove-identity-welcome/index-existing-session.njk"
: "prove-identity-welcome/index.njk",
{
redirectUri: createServiceRedirectErrorUrl(
req.session.client.redirectUri,
OIDC_ERRORS.ACCESS_DENIED,
IPV_ERROR_CODES.ACCOUNT_NOT_CREATED,
req.session.client.state
),
supportLanguageCY: supportLanguageCY() ? true : null,
}
);
}

export function proveIdentityWelcomePost(req: Request, res: Response): void {
const redirect = req.body.chooseWayPyi === "redirect";

if (redirect) {
return res.redirect(
createServiceRedirectErrorUrl(
req.session.client.redirectUri,
OIDC_ERRORS.ACCESS_DENIED,
IPV_ERROR_CODES.ACCOUNT_NOT_CREATED,
req.session.client.state
)
);
}

const event = req.session.user.isAuthenticated
? USER_JOURNEY_EVENTS.EXISTING_SESSION
: USER_JOURNEY_EVENTS.CREATE_OR_SIGN_IN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ import { describe } from "mocha";
import { sinon } from "../../../../test/utils/test-utils";
import { Request, Response } from "express";

import {
IPV_ERROR_CODES,
OIDC_ERRORS,
OIDC_PROMPT,
PATH_NAMES,
} from "../../../app.constants";
import { OIDC_PROMPT, PATH_NAMES } from "../../../app.constants";
import {
mockRequest,
mockResponse,
Expand Down Expand Up @@ -76,19 +71,6 @@ describe("prove your identity welcome controller", () => {
);
});

it("should redirect to RP redirect URI when using alternative way to prove your identity", async () => {
req.body.chooseWayPyi = "redirect";
proveIdentityWelcomePost(req as Request, res as Response);

expect(res.redirect).to.have.been.calledWith(
`http://someservice.com/auth?error=${
OIDC_ERRORS.ACCESS_DENIED
}&error_description=${encodeURIComponent(
IPV_ERROR_CODES.ACCOUNT_NOT_CREATED
)}&state=${encodeURIComponent(STATE)}`
);
});

it("should redirect to prove your identity when user is authenticated", async () => {
req.session.user.isAuthenticated = true;
proveIdentityWelcomePost(req as Request, res as Response);
Expand Down

0 comments on commit 98a6fb4

Please sign in to comment.