Skip to content

Commit

Permalink
Merge pull request #1705 from nmro184/Add-security-step-before-deleti…
Browse files Browse the repository at this point in the history
…ng-user-account

added security step before account deletion
  • Loading branch information
RodriSanchez1 authored Jul 22, 2024
2 parents eb91845 + 10c471d commit 295f0f6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
30 changes: 27 additions & 3 deletions src/components/Settings/People/DeleteConfirmationDialog.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import React, { useState } from 'react';
import PropTypes from 'prop-types';

import TextField from '@material-ui/core/TextField';
import { FormattedMessage } from 'react-intl';
import messages from './People.messages';

Expand Down Expand Up @@ -31,6 +31,18 @@ const DeleteConfirmationDialog = ({
isDeletingAccount,
errorDeletingAccount
}) => {
const DELETE_ACCOUNT = 'delete-account';
const [confirmationText, setConfirmationText] = useState('');

const handleConfirmationChange = e => {
setConfirmationText(e.target.value);
};

const handleDialogClose = () => {
setConfirmationText('');
handleClose();
};

return (
<Dialog
open={open}
Expand All @@ -51,18 +63,30 @@ const DeleteConfirmationDialog = ({
<FormattedMessage {...messages.deleteAccountConfirmation} />
</DialogContentText>
)}
<TextField
autoFocus={true}
fullWidth={true}
label={
<FormattedMessage
{...messages.deleteAccountFinal}
values={{ deleteAccount: DELETE_ACCOUNT }}
/>
}
onChange={handleConfirmationChange}
/>
</DialogContent>
{!isDeletingAccount && (
<DialogActions>
<Button
variant="outlined"
color="secondary"
className={'delete_button'}
disabled={confirmationText !== DELETE_ACCOUNT}
onClick={handleDeleteConfirmed}
>
{<FormattedMessage {...messages.deleteAccountPrimary} />}
</Button>
<Button variant="outlined" onClick={handleClose} autoFocus>
<Button variant="outlined" onClick={handleDialogClose} autoFocus>
{<FormattedMessage {...messages.cancelDeleteAccount} />}
</Button>
</DialogActions>
Expand Down
4 changes: 4 additions & 0 deletions src/components/Settings/People/People.messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ export default defineMessages({
defaultMessage:
'Once you delete an account, there is no going back. Please be certain.'
},
deleteAccountFinal: {
id: 'cboard.components.Settings.People.deleteAccountFinal',
defaultMessage: 'To confirm, type "{deleteAccount}".'
},
errorDeletingAccount: {
id: 'cboard.components.Settings.People.errorDeletingAccount',
defaultMessage:
Expand Down

0 comments on commit 295f0f6

Please sign in to comment.