Skip to content

Commit 1ca44cd

Browse files
committedMay 27, 2020
feat(api): remove account deletion
1 parent 71a3d4b commit 1ca44cd

File tree

8 files changed

+3
-128
lines changed

8 files changed

+3
-128
lines changed
 

‎artillery/rctf.yml

-7
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,3 @@ scenarios:
4141
url: "/api/v1/users/me"
4242
headers:
4343
Authorization: "Bearer {{ token }}"
44-
- delete:
45-
url: "/api/v1/users/me"
46-
headers:
47-
Authorization: "Bearer {{ token }}"
48-
49-
50-

‎client/src/api/profile.js

+1-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { request, relog, handleResponse } from './util'
1+
import { request, handleResponse } from './util'
22

33
export const privateProfile = async () => {
44
const resp = await request('GET', '/users/me')
@@ -12,19 +12,6 @@ export const publicProfile = async (uuid) => {
1212
return handleResponse({ resp, valid: ['goodUserData'] })
1313
}
1414

15-
export const deleteAccount = async () => {
16-
const resp = await request('DELETE', '/users/me')
17-
18-
switch (resp.kind) {
19-
case 'goodUserDelete':
20-
return relog()
21-
default:
22-
return {
23-
error: resp.message
24-
}
25-
}
26-
}
27-
2815
export const updateAccount = async ({ name, division }) => {
2916
const resp = await request('PATCH', '/users/me', {
3017
name,

‎client/src/routes/profile.js

+1-70
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ import { memo } from 'preact/compat'
33
import config from '../config'
44
import withStyles from '../components/jss'
55

6-
import { privateProfile, publicProfile, deleteAccount, updateAccount, updateEmail, deleteEmail } from '../api/profile'
6+
import { privateProfile, publicProfile, updateAccount, updateEmail, deleteEmail } from '../api/profile'
77
import { useToast } from '../components/toast'
88
import Form from '../components/form'
9-
import Modal from '../components/modal'
109
import MembersCard from '../components/profile/memberscard'
1110
import TokenPreview from '../components/tokenPreview'
1211
import * as util from '../util'
@@ -23,66 +22,6 @@ for (const division of Object.entries(config.divisions)) {
2322
divisionMap.set(division[1], division[0])
2423
}
2524

26-
const DeleteModal = withStyles({
27-
modalBody: {
28-
paddingTop: '0em !important' // reduce space between header and body
29-
},
30-
controls: {
31-
display: 'flex',
32-
justifyContent: 'center',
33-
'& :first-child': {
34-
marginLeft: '0em'
35-
},
36-
'& :last-child': {
37-
marginRight: '0em'
38-
}
39-
}
40-
}, ({ open, onClose, onSuccess, teamName, classes }) => {
41-
const [inputName, setInputName] = useState('')
42-
const handleInputNameChange = useCallback((e) => setInputName(e.target.value), [])
43-
const isNameValid = inputName === teamName
44-
const verifyName = useCallback((e) => {
45-
e.preventDefault()
46-
if (isNameValid) {
47-
onSuccess()
48-
}
49-
}, [isNameValid, onSuccess])
50-
const wrappedOnClose = useCallback((e) => {
51-
e.preventDefault()
52-
onClose()
53-
}, [onClose])
54-
55-
useEffect(() => {
56-
if (!open) {
57-
setInputName('')
58-
}
59-
}, [open])
60-
61-
return (
62-
<Modal {...{ open, onClose }}>
63-
<div class='modal-header'>
64-
<div class='modal-title'>Delete Account</div>
65-
</div>
66-
{/* Put buttons in the body because otherwise there is too much padding */}
67-
<form class={`modal-body ${classes.modalBody}`} onSubmit={verifyName}>
68-
<div>Are you sure you want to delete your team? This action is permanent.</div>
69-
<div class='form-section'>
70-
<label>Type your team name to confirm:</label>
71-
<input placeholder={teamName} value={inputName} onInput={handleInputNameChange} />
72-
</div>
73-
<div class={`${classes.controls}`}>
74-
<div class='btn-container u-inline-block'>
75-
<button class='btn-small' onClick={wrappedOnClose}>Cancel</button>
76-
</div>
77-
<div class='btn-container u-inline-block'>
78-
<input type='submit' class='btn-small btn-danger outline' disabled={!isNameValid} value='Delete Team' />
79-
</div>
80-
</div>
81-
</form>
82-
</Modal>
83-
)
84-
})
85-
8625
const SummaryCard = memo(withStyles({
8726
icon: {
8827
'& svg': {
@@ -208,10 +147,6 @@ const UpdateCard = withStyles({
208147
}, ({ name: oldName, email: oldEmail, onUpdate, classes }) => {
209148
const { toast } = useToast()
210149

211-
const [deleteModalVisible, setDeleteModalVisible] = useState(false)
212-
const dismissDeleteModal = useCallback(() => setDeleteModalVisible(false), [])
213-
const handleDelete = useCallback(() => setDeleteModalVisible(true), [])
214-
215150
const [name, setName] = useState(oldName)
216151
const handleSetName = useCallback((e) => setName(e.target.value), [])
217152

@@ -293,10 +228,6 @@ const UpdateCard = withStyles({
293228
<input required icon={<EnvelopeOpen />} name='email' placeholder='Email' type='email' value={email} onChange={handleSetEmail} />
294229
</Form>
295230
</div>
296-
<div class='u-center action-bar' style='margin: 0.5rem; padding: 1rem'>
297-
<button class='btn-small btn-danger outline' style='border-color: var(--btn-color)' onClick={handleDelete}>Delete Account</button>
298-
<DeleteModal open={deleteModalVisible} onClose={dismissDeleteModal} onSuccess={deleteAccount} teamName={name} />
299-
</div>
300231
</div>
301232
</div>
302233
)

‎server/api/users/delete.js

-16
This file was deleted.

‎server/api/users/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export default [
77
...require('./members').default,
88
require('./me').default,
99
require('./id').default,
10-
require('./delete').default,
1110
require('./update').default,
1211
...require('./me-auth/ctftime').default,
1312
...require('./me-auth/email').default

‎server/responses/index.js

-4
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,6 @@ export const responseList = {
155155
status: 200,
156156
message: 'The user data was successfully retrieved.'
157157
},
158-
goodUserDelete: {
159-
status: 200,
160-
message: 'Your account was successfully deleted'
161-
},
162158
goodUserUpdate: {
163159
status: 200,
164160
message: 'Your account was successfully updated'

‎server/util/emails/verify.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ To verify your email and recover your {{{ ctf_name }}} account, click the link b
1414
Update your {{{ ctf_name }}} email
1515

1616
Before we add this email to your account, we need to make sure it's actually you.
17-
To add this email to your {{{ ctf_name }}} account, click the button below.
17+
To add this email to your {{{ ctf_name }}} account, click the link below.
1818
{{ /update }}
1919

2020
{{{ origin }}}/verify#token={{{ token }}}

‎test/integration/auth.js

-15
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,3 @@ test.serial('succeeds with goodUserUpdate', async t => {
120120
t.is(respUser.email, testUser.email)
121121
t.is(respUser.division, nextUser.division)
122122
})
123-
124-
test.serial('succeeds with goodUserDelete', async t => {
125-
const user = await database.auth.getUserByEmail({
126-
email: testUser.email
127-
})
128-
129-
const authToken = await auth.token.getToken(auth.token.tokenKinds.auth, user.id)
130-
131-
const resp = await request(app)
132-
.delete(process.env.API_ENDPOINT + '/users/me')
133-
.set('Authorization', ' Bearer ' + authToken)
134-
.expect(responseList.goodUserDelete.status)
135-
136-
t.is(resp.body.kind, 'goodUserDelete')
137-
})

0 commit comments

Comments
 (0)
Please sign in to comment.