Skip to content

Commit c68e880

Browse files
committed
delete account changes (WIP)
1 parent 3aa63e4 commit c68e880

2 files changed

Lines changed: 1 addition & 68 deletions

File tree

src/client/pages/DeleteAccount.tsx

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import React, { useState } from 'react';
21
import { RadioGroup, Radio } from '@guardian/source/react-components';
32
import { MainForm } from '@/client/components/MainForm';
43
import { MainBodyText } from '@/client/components/MainBodyText';
54
import { ExternalLink } from '@/client/components/ExternalLink';
65
import locations from '@/shared/lib/locations';
7-
import { PasswordInput } from '@/client/components/PasswordInput';
86
import { Divider } from '@guardian/source-development-kitchen/react-components';
97
import { DeleteAccountReturnLink } from '@/client/components/DeleteAccountReturnLink';
108
import { buildUrlWithQueryParams } from '@/shared/lib/routeUtils';
@@ -37,15 +35,10 @@ const radioGroupStyles = css`
3735

3836
export const DeleteAccount = ({
3937
queryParams,
40-
fieldErrors = [],
4138
formError,
4239
error,
4340
shortRequestId,
4441
}: Props) => {
45-
const [passwordError] = useState<string | undefined>(
46-
fieldErrors.find((fieldError) => fieldError.field === 'password')?.message,
47-
);
48-
4942
return (
5043
<MinimalLayout
5144
shortRequestId={shortRequestId}
@@ -228,16 +221,6 @@ export const DeleteAccount = ({
228221
<MainBodyText>
229222
<strong>Confirm account deletion</strong>
230223
</MainBodyText>
231-
<MainBodyText>
232-
Please re-enter password to confirm the you have understood the
233-
conditions and would like to proceed with account deletion.
234-
</MainBodyText>
235-
{/* password input */}
236-
<PasswordInput
237-
error={passwordError}
238-
label="Password"
239-
autoComplete="current-password"
240-
/>
241224
</MainForm>
242225
<DeleteAccountReturnLink />
243226
</MinimalLayout>

src/server/routes/delete.ts

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { ApiError } from '@/server/models/Error';
99
import { logger } from '@/server/lib/serverSideLogger';
1010
import { mergeRequestState } from '@/server/lib/requestState';
1111
import { getUser } from '@/server/lib/okta/api/users';
12-
import { authenticate } from '@/server/lib/okta/api/authentication';
1312
import { OktaError } from '@/server/models/okta/Error';
1413
import {
1514
performAuthorizationCodeFlow,
@@ -87,31 +86,6 @@ router.get(
8786
return res.type('html').send(html);
8887
}
8988

90-
// check if the user has a password set
91-
if (
92-
!user.credentials.password ||
93-
/**
94-
* Playwright Test
95-
*
96-
* This code checks if we're running in Playwright to
97-
* mock the user's password
98-
*/
99-
(runningInPlaywright && playwrightMockStateCookie === 'noPassword')
100-
) {
101-
// if not, ask them to set a password
102-
const html = renderer('/delete-set-password', {
103-
pageTitle: 'Create Password',
104-
requestState: mergeRequestState(state, {
105-
queryParams: {
106-
...state.queryParams,
107-
// force the returnUrl to be the delete page after setting a password
108-
returnUrl: joinUrl(profileUrl, req.path),
109-
},
110-
}),
111-
});
112-
return res.type('html').send(html);
113-
}
114-
11589
// get the user's attributes from the members data api
11690
const userAttributes = await getUserAttributes({
11791
accessToken: state.oauthState.accessToken.toString(),
@@ -251,31 +225,7 @@ router.post(
251225
);
252226
}
253227

254-
const { password = '' } = req.body;
255-
256228
try {
257-
const { email } = state.oauthState.idToken.claims;
258-
259-
// attempt to authenticate with okta
260-
// if authentication fails, it will fall through to the catch
261-
const response = await authenticate(
262-
{
263-
username: email as string,
264-
password,
265-
},
266-
req.ip,
267-
);
268-
269-
// we only support the SUCCESS status for Okta authentication in gateway
270-
// Other statuses could be supported in the future https://developer.okta.com/docs/reference/api/authn/#transaction-state
271-
if (response.status !== 'SUCCESS') {
272-
throw new ApiError({
273-
message:
274-
'User authenticating was blocked due to unsupported Okta Authentication status property',
275-
status: 403,
276-
});
277-
}
278-
279229
// perform the authorization code flow to get an access token specifically for deleting the user
280230
return performAuthorizationCodeFlow(req, res, {
281231
redirectUri: ProfileOpenIdClientRedirectUris.DELETE,
@@ -294,7 +244,7 @@ router.post(
294244
fieldErrors: [
295245
{
296246
field: 'password',
297-
message: 'Password is incorrect',
247+
message: 'Password is incorrect', //todo
298248
},
299249
],
300250
},

0 commit comments

Comments
 (0)