Skip to content

Commit

Permalink
ATO-387: Remove consentRequired
Browse files Browse the repository at this point in the history
  • Loading branch information
hannah-leong committed May 24, 2024
1 parent 4fb1eb9 commit 0f6c56b
Show file tree
Hide file tree
Showing 25 changed files with 7 additions and 126 deletions.
3 changes: 0 additions & 3 deletions src/components/account-created/account-created-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ export async function accountCreatedPost(
req,
req.path,
USER_JOURNEY_EVENTS.ACCOUNT_CREATED,
{
isConsentRequired: req.session.user.isConsentRequired,
},
res.locals.sessionId
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,5 @@ describe("account created controller", () => {

expect(res.redirect).to.have.been.calledWith(PATH_NAMES.AUTH_CODE);
});
it("should redirect to share-info when consent is required", async () => {
req.session.user.isConsentRequired = true;
await accountCreatedPost(req as Request, res as Response);

expect(res.redirect).to.have.been.calledWith(PATH_NAMES.SHARE_INFO);
});
});
});
5 changes: 0 additions & 5 deletions src/components/authorize/authorize-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ export function authorizeGet(
req.session.client.rpSectorHost = claims.rp_sector_host;
req.session.client.rpRedirectUri = claims.rp_redirect_uri;
req.session.client.rpState = claims.rp_state;

req.session.client.consentEnabled =
startAuthResponse.data.user.consentRequired;

req.session.user.isIdentityRequired =
startAuthResponse.data.user.identityRequired;
req.session.user.isAuthenticated =
Expand Down Expand Up @@ -134,7 +130,6 @@ export function authorizeGet(
PATH_NAMES.AUTHORIZE,
nextStateEvent,
{
isConsentRequired: req.session.client.consentEnabled,
requiresUplift: req.session.user.isUpliftRequired,
isIdentityRequired: req.session.user.isIdentityRequired,
isAuthenticated: req.session.user.isAuthenticated,
Expand Down
2 changes: 0 additions & 2 deletions src/components/authorize/claims-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export type Claims = {
jti: string;
client_name: string;
cookie_consent_shared: boolean;
consent_required: boolean;
is_one_login_service: boolean;
service_type: string;
govuk_signin_journey_id: string;
Expand All @@ -45,7 +44,6 @@ export const requiredClaimsKeys = [
"jti",
"client_name",
"cookie_consent_shared",
"consent_required",
"is_one_login_service",
"service_type",
"govuk_signin_journey_id",
Expand Down
25 changes: 0 additions & 25 deletions src/components/authorize/tests/authorize-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ describe("authorize controller", () => {
fakeAuthorizeService = mockAuthService({
data: {
user: {
consentRequired: false,
identityRequired: false,
upliftRequired: false,
authenticated: true,
Expand Down Expand Up @@ -179,28 +178,8 @@ describe("authorize controller", () => {
expect(res.redirect).to.have.calledWith(PATH_NAMES.AUTH_CODE);
});

it("should redirect to /share-info when consent required", async () => {
authServiceResponseData.data.user = {
consentRequired: true,
identityRequired: false,
upliftRequired: false,
authenticated: true,
};
fakeAuthorizeService = mockAuthService(authServiceResponseData);

await authorizeGet(
fakeAuthorizeService,
fakeCookieConsentService,
fakeKmsDecryptionService,
fakeJwtService
)(req as Request, res as Response);

expect(res.redirect).to.have.calledWith(PATH_NAMES.SHARE_INFO);
});

it("should redirect to /identity page when identity check required", async () => {
authServiceResponseData.data.user = {
consentRequired: false,
identityRequired: true,
upliftRequired: false,
authenticated: true,
Expand All @@ -223,7 +202,6 @@ describe("authorize controller", () => {
process.env.SUPPORT_REAUTHENTICATION = "1";
mockClaims.reauthenticate = "123456";
authServiceResponseData.data.user = {
consentRequired: false,
identityRequired: false,
upliftRequired: false,
authenticated: false,
Expand All @@ -245,7 +223,6 @@ describe("authorize controller", () => {
process.env.SUPPORT_REAUTHENTICATION = "0";
mockClaims.reauthenticate = "123456";
authServiceResponseData.data.user = {
consentRequired: false,
identityRequired: false,
upliftRequired: false,
authenticated: false,
Expand Down Expand Up @@ -278,7 +255,6 @@ describe("authorize controller", () => {
it("should redirect to /sign-in-or-create page with _ga query param when present", async () => {
const gaTrackingId = "2.172053219.3232.1636392870-444224.1635165988";
authServiceResponseData.data.user = {
consentRequired: false,
identityRequired: false,
upliftRequired: false,
cookieConsent: COOKIE_CONSENT.ACCEPT,
Expand Down Expand Up @@ -321,7 +297,6 @@ describe("authorize controller", () => {
it("should redirect to /doc-checking-app when doc check app user", async () => {
authServiceResponseData.data.user = {
authenticated: false,
consentRequired: false,
docCheckingAppUser: true,
};
fakeAuthorizeService = mockAuthService(authServiceResponseData);
Expand Down
2 changes: 0 additions & 2 deletions src/components/authorize/tests/authorize-integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ describe("Integration:: authorize", () => {
serviceType: "MANDATORY",
clientName: "test-client",
cookieConsentEnabled: true,
consentEnabled: true,
redirectUri: "http://test-redirect.gov.uk/callback",
state: "jasldasl12312",
isOneLoginService: false,
},
user: {
consentRequired: true,
upliftRequired: false,
identityRequired: false,
authenticated: false,
Expand Down
1 change: 0 additions & 1 deletion src/components/authorize/tests/test-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export function createmockclaims(): any {
return {
confidence: "Cl.Cm",
iss: "UNKNOWN",
consent_required: false,
client_id: getOrchToAuthExpectedClientId(),
govuk_signin_journey_id: "QOFzoB3o-9gGplMgdT1dJfH4vaI",
aud: getOrchToAuthExpectedAudience(),
Expand Down
1 change: 0 additions & 1 deletion src/components/authorize/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export interface StartAuthResponse extends DefaultApiResponse {
export interface UserSessionInfo {
upliftRequired: boolean;
identityRequired: boolean;
consentRequired: boolean;
authenticated: boolean;
cookieConsent?: string;
gaCrossDomainTrackingId?: string;
Expand Down
1 change: 0 additions & 1 deletion src/components/common/mfa/send-mfa-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export function sendMfaGeneric(
{
isLatestTermsAndConditionsAccepted:
req.session.user.isLatestTermsAndConditionsAccepted,
isConsentRequired: req.session.user.isConsentRequired,
isIdentityRequired: req.session.user.isIdentityRequired,
},
sessionId
Expand Down
42 changes: 0 additions & 42 deletions src/components/common/state-machine/state-machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ const authStateMachine = createMachine(
initial: PATH_NAMES.AUTHORIZE,
context: {
isLatestTermsAndConditionsAccepted: true,
isConsentRequired: false,
requiresUplift: false,
requiresTwoFactorAuth: false,
isAuthenticated: false,
Expand Down Expand Up @@ -101,10 +100,6 @@ const authStateMachine = createMachine(
cond: "requiresAuthAppUplift",
},
{ target: [PATH_NAMES.UPLIFT_JOURNEY], cond: "requiresUplift" },
{
target: [PATH_NAMES.SHARE_INFO],
cond: "isConsentRequired",
},
{
target: [PATH_NAMES.ENTER_EMAIL_SIGN_IN],
cond: "isReauthenticationRequired",
Expand Down Expand Up @@ -232,10 +227,6 @@ const authStateMachine = createMachine(
target: [PATH_NAMES.UPDATED_TERMS_AND_CONDITIONS],
cond: "isLatestTermsAndConditionsAccepted",
},
{
target: [PATH_NAMES.SHARE_INFO],
cond: "isConsentRequired",
},
{ target: [PATH_NAMES.AUTH_CODE] },
],
},
Expand Down Expand Up @@ -328,10 +319,6 @@ const authStateMachine = createMachine(
target: [PATH_NAMES.PROVE_IDENTITY],
cond: "isIdentityRequired",
},
{
target: [PATH_NAMES.SHARE_INFO],
cond: "isConsentRequired",
},
{ target: [PATH_NAMES.CREATE_ACCOUNT_SUCCESSFUL] },
],
},
Expand All @@ -350,10 +337,6 @@ const authStateMachine = createMachine(
[PATH_NAMES.CREATE_ACCOUNT_SUCCESSFUL]: {
on: {
[USER_JOURNEY_EVENTS.ACCOUNT_CREATED]: [
{
target: [PATH_NAMES.SHARE_INFO],
cond: "isConsentRequired",
},
{ target: [PATH_NAMES.AUTH_CODE] },
],
},
Expand Down Expand Up @@ -389,10 +372,6 @@ const authStateMachine = createMachine(
target: [PATH_NAMES.UPDATED_TERMS_AND_CONDITIONS],
cond: "isLatestTermsAndConditionsAccepted",
},
{
target: [PATH_NAMES.SHARE_INFO],
cond: "isConsentRequired",
},
{ target: [PATH_NAMES.AUTH_CODE] },
],
},
Expand All @@ -417,10 +396,6 @@ const authStateMachine = createMachine(
target: [PATH_NAMES.PROVE_IDENTITY],
cond: "isIdentityRequired",
},
{
target: [PATH_NAMES.SHARE_INFO],
cond: "isConsentRequired",
},
{ target: [PATH_NAMES.AUTH_CODE] },
],
[USER_JOURNEY_EVENTS.CHANGE_SECURITY_CODES_REQUESTED]: [
Expand Down Expand Up @@ -448,10 +423,6 @@ const authStateMachine = createMachine(
target: [PATH_NAMES.PROVE_IDENTITY],
cond: "isIdentityRequired",
},
{
target: [PATH_NAMES.SHARE_INFO],
cond: "isConsentRequired",
},
{ target: [PATH_NAMES.AUTH_CODE] },
],
},
Expand All @@ -475,10 +446,6 @@ const authStateMachine = createMachine(
target: [PATH_NAMES.PROVE_IDENTITY],
cond: "isIdentityRequired",
},
{
target: [PATH_NAMES.SHARE_INFO],
cond: "isConsentRequired",
},
{ target: [PATH_NAMES.AUTH_CODE] },
],
},
Expand Down Expand Up @@ -585,10 +552,6 @@ const authStateMachine = createMachine(
target: [PATH_NAMES.UPDATED_TERMS_AND_CONDITIONS],
cond: "isLatestTermsAndConditionsAccepted",
},
{
target: [PATH_NAMES.SHARE_INFO],
cond: "isConsentRequired",
},
{
target: [PATH_NAMES.PROVE_IDENTITY],
cond: "isIdentityRequired",
Expand Down Expand Up @@ -634,10 +597,6 @@ const authStateMachine = createMachine(
target: [PATH_NAMES.UPDATED_TERMS_AND_CONDITIONS],
cond: "isLatestTermsAndConditionsAccepted",
},
{
target: [PATH_NAMES.SHARE_INFO],
cond: "isConsentRequired",
},
{ target: [PATH_NAMES.AUTH_CODE] },
],
},
Expand Down Expand Up @@ -767,7 +726,6 @@ const authStateMachine = createMachine(
},
{
guards: {
isConsentRequired: (context) => context.isConsentRequired === true,
isLatestTermsAndConditionsAccepted: (context) =>
context.isLatestTermsAndConditionsAccepted === false,
requiresUplift: (context) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ export function verifyCodePost(
nextEvent,
{
isIdentityRequired: req.session.user.isIdentityRequired,
isConsentRequired: req.session.user.isConsentRequired,
isLatestTermsAndConditionsAccepted:
req.session.user.isLatestTermsAndConditionsAccepted,
support2FABeforePasswordReset: support2FABeforePasswordReset(),
Expand Down
2 changes: 0 additions & 2 deletions src/components/create-password/create-password-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ export function createPasswordPost(
throw new BadRequestError(result.data.message, result.data.code);
}

req.session.user.isConsentRequired = result.data.consentRequired;

return res.redirect(
await getNextPathAndUpdateJourney(
req,
Expand Down
10 changes: 5 additions & 5 deletions src/components/create-password/create-password-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
http,
} from "../../utils/http";
import { API_ENDPOINTS } from "../../app.constants";
import { CreatePasswordServiceInterface, SignUpResponse } from "./types";
import { ApiResponseResult } from "../../types";
import { CreatePasswordServiceInterface } from "./types";
import { ApiResponseResult, DefaultApiResponse } from "../../types";
import { Request } from "express";

export function createPasswordService(
Expand All @@ -20,8 +20,8 @@ export function createPasswordService(
sourceIp: string,
persistentSessionId: string,
req: Request
): Promise<ApiResponseResult<SignUpResponse>> {
const response = await axios.client.post<SignUpResponse>(
): Promise<ApiResponseResult<DefaultApiResponse>> {
const response = await axios.client.post<DefaultApiResponse>(
API_ENDPOINTS.SIGNUP_USER,
{
email: emailAddress,
Expand All @@ -39,7 +39,7 @@ export function createPasswordService(
)
);

return createApiResponse<SignUpResponse>(response);
return createApiResponse<DefaultApiResponse>(response);
};

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ describe("create-password controller", () => {
it("should redirect to get security codes when 2 factor is required", async () => {
const fakeService: CreatePasswordServiceInterface = {
signUpUser: sinon.fake.returns({
data: {
consentRequired: false,
},
success: true,
}),
} as unknown as CreatePasswordServiceInterface;
Expand Down
8 changes: 2 additions & 6 deletions src/components/create-password/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ export interface CreatePasswordServiceInterface {
emailAddress: string,
password: string,
sourceIp: string,
persistentSessionId: string,
persistentSessionId: string
req: Request
) => Promise<ApiResponseResult<SignUpResponse>>;
}

export interface SignUpResponse extends DefaultApiResponse {
consentRequired: boolean;
) => Promise<ApiResponseResult<DefaultApiResponse>>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ export const enterAuthenticatorAppCodePost = (
USER_JOURNEY_EVENTS.AUTH_APP_CODE_VERIFIED,
{
isIdentityRequired: req.session.user.isIdentityRequired,
isConsentRequired: req.session.user.isConsentRequired,
isLatestTermsAndConditionsAccepted:
req.session.user.isLatestTermsAndConditionsAccepted,
},
Expand Down
2 changes: 0 additions & 2 deletions src/components/enter-password/enter-password-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ export function enterPasswordPost(
const isPasswordChangeRequired = userLogin.data.passwordChangeRequired;

req.session.user.redactedPhoneNumber = userLogin.data.redactedPhoneNumber;
req.session.user.isConsentRequired = userLogin.data.consentRequired;
req.session.user.isAccountPartCreated = !userLogin.data.mfaMethodVerified;
req.session.user.isLatestTermsAndConditionsAccepted =
userLogin.data.latestTermsAndConditionsAccepted;
Expand Down Expand Up @@ -248,7 +247,6 @@ export function enterPasswordPost(
isLatestTermsAndConditionsAccepted:
req.session.user.isLatestTermsAndConditionsAccepted,
requiresTwoFactorAuth: userLogin.data.mfaRequired,
isConsentRequired: req.session.user.isConsentRequired,
mfaMethodType: userLogin.data.mfaMethodType,
isMfaMethodVerified: userLogin.data.mfaMethodVerified,
isPasswordChangeRequired: isPasswordChangeRequired,
Expand Down
Loading

0 comments on commit 0f6c56b

Please sign in to comment.