Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions artillery/rctf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,3 @@ scenarios:
url: "/api/v1/users/me"
headers:
Authorization: "Bearer {{ token }}"
- delete:
url: "/api/v1/users/me"
headers:
Authorization: "Bearer {{ token }}"



15 changes: 1 addition & 14 deletions client/src/api/profile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { request, relog, handleResponse } from './util'
import { request, handleResponse } from './util'

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

export const deleteAccount = async () => {
const resp = await request('DELETE', '/users/me')

switch (resp.kind) {
case 'goodUserDelete':
return relog()
default:
return {
error: resp.message
}
}
}

export const updateAccount = async ({ name, division }) => {
const resp = await request('PATCH', '/users/me', {
name,
Expand Down
71 changes: 1 addition & 70 deletions client/src/routes/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import { memo } from 'preact/compat'
import config from '../config'
import withStyles from '../components/jss'

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

const DeleteModal = withStyles({
modalBody: {
paddingTop: '0em !important' // reduce space between header and body
},
controls: {
display: 'flex',
justifyContent: 'center',
'& :first-child': {
marginLeft: '0em'
},
'& :last-child': {
marginRight: '0em'
}
}
}, ({ open, onClose, onSuccess, teamName, classes }) => {
const [inputName, setInputName] = useState('')
const handleInputNameChange = useCallback((e) => setInputName(e.target.value), [])
const isNameValid = inputName === teamName
const verifyName = useCallback((e) => {
e.preventDefault()
if (isNameValid) {
onSuccess()
}
}, [isNameValid, onSuccess])
const wrappedOnClose = useCallback((e) => {
e.preventDefault()
onClose()
}, [onClose])

useEffect(() => {
if (!open) {
setInputName('')
}
}, [open])

return (
<Modal {...{ open, onClose }}>
<div class='modal-header'>
<div class='modal-title'>Delete Account</div>
</div>
{/* Put buttons in the body because otherwise there is too much padding */}
<form class={`modal-body ${classes.modalBody}`} onSubmit={verifyName}>
<div>Are you sure you want to delete your team? This action is permanent.</div>
<div class='form-section'>
<label>Type your team name to confirm:</label>
<input placeholder={teamName} value={inputName} onInput={handleInputNameChange} />
</div>
<div class={`${classes.controls}`}>
<div class='btn-container u-inline-block'>
<button class='btn-small' onClick={wrappedOnClose}>Cancel</button>
</div>
<div class='btn-container u-inline-block'>
<input type='submit' class='btn-small btn-danger outline' disabled={!isNameValid} value='Delete Team' />
</div>
</div>
</form>
</Modal>
)
})

const SummaryCard = memo(withStyles({
icon: {
'& svg': {
Expand Down Expand Up @@ -208,10 +147,6 @@ const UpdateCard = withStyles({
}, ({ name: oldName, email: oldEmail, onUpdate, classes }) => {
const { toast } = useToast()

const [deleteModalVisible, setDeleteModalVisible] = useState(false)
const dismissDeleteModal = useCallback(() => setDeleteModalVisible(false), [])
const handleDelete = useCallback(() => setDeleteModalVisible(true), [])

const [name, setName] = useState(oldName)
const handleSetName = useCallback((e) => setName(e.target.value), [])

Expand Down Expand Up @@ -293,10 +228,6 @@ const UpdateCard = withStyles({
<input required icon={<EnvelopeOpen />} name='email' placeholder='Email' type='email' value={email} onChange={handleSetEmail} />
</Form>
</div>
<div class='u-center action-bar' style='margin: 0.5rem; padding: 1rem'>
<button class='btn-small btn-danger outline' style='border-color: var(--btn-color)' onClick={handleDelete}>Delete Account</button>
<DeleteModal open={deleteModalVisible} onClose={dismissDeleteModal} onSuccess={deleteAccount} teamName={name} />
</div>
</div>
</div>
)
Expand Down
16 changes: 0 additions & 16 deletions server/api/users/delete.js

This file was deleted.

1 change: 0 additions & 1 deletion server/api/users/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export default [
...require('./members').default,
require('./me').default,
require('./id').default,
require('./delete').default,
require('./update').default,
...require('./me-auth/ctftime').default,
...require('./me-auth/email').default
Expand Down
4 changes: 0 additions & 4 deletions server/responses/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,6 @@ export const responseList = {
status: 200,
message: 'The user data was successfully retrieved.'
},
goodUserDelete: {
status: 200,
message: 'Your account was successfully deleted'
},
goodUserUpdate: {
status: 200,
message: 'Your account was successfully updated'
Expand Down
2 changes: 1 addition & 1 deletion server/util/emails/verify.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ To verify your email and recover your {{{ ctf_name }}} account, click the link b
Update your {{{ ctf_name }}} email

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

{{{ origin }}}/verify#token={{{ token }}}
Expand Down
15 changes: 0 additions & 15 deletions test/integration/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,3 @@ test.serial('succeeds with goodUserUpdate', async t => {
t.is(respUser.email, testUser.email)
t.is(respUser.division, nextUser.division)
})

test.serial('succeeds with goodUserDelete', async t => {
const user = await database.auth.getUserByEmail({
email: testUser.email
})

const authToken = await auth.token.getToken(auth.token.tokenKinds.auth, user.id)

const resp = await request(app)
.delete(process.env.API_ENDPOINT + '/users/me')
.set('Authorization', ' Bearer ' + authToken)
.expect(responseList.goodUserDelete.status)

t.is(resp.body.kind, 'goodUserDelete')
})