Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Added ability to delete user account

Blaumaus3ffaf7a54b65
diff --git a/src/pages/UserSettings/UserSettings.container.jsx b/src/pages/UserSettings/UserSettings.container.jsx
index c89ce7050..b62b95c70 100644
--- a/src/pages/UserSettings/UserSettings.container.jsx
+++ b/src/pages/UserSettings/UserSettings.container.jsx
@@ -1,13 +1,21 @@
import React from 'react'
import { useDispatch } from 'react-redux'
+import { authActions } from 'actions/auth'
+import { errorsActions } from 'actions/errors'
import UserSettings from './UserSettings'
export default () => {
const dispatch = useDispatch()
const onDelete = () => {
- // TODO
+ dispatch(
+ authActions.deleteAccountAsync(
+ (error) => dispatch(
+ errorsActions.deleteAccountFailed(error.description)
+ )
+ )
+ )
}
const onExport = () => {
diff --git a/src/pages/UserSettings/UserSettings.jsx b/src/pages/UserSettings/UserSettings.jsx
index f22553e58..d74937fe6 100644
--- a/src/pages/UserSettings/UserSettings.jsx
+++ b/src/pages/UserSettings/UserSettings.jsx
@@ -3,6 +3,7 @@ import { useSelector } from 'react-redux'
import Form from 'react-bootstrap/Form'
import { Mailbox } from 'react-bootstrap-icons'
+import Modal from 'components/Modal'
import { isValidEmail, isValidPassword } from 'utils/validator'
export default ({ onDelete, onExport, onSubmit, onEmailConfirm }) => {
@@ -16,6 +17,7 @@ export default ({ onDelete, onExport, onSubmit, onEmailConfirm }) => {
const [validated, setValidated] = useState(false)
const [errors, setErrors] = useState({})
const [beenSubmitted, setBeenSubmitted] = useState(false)
+ const [showModal, setShowModal] = useState(false)
useEffect(() => {
validate()
@@ -48,18 +50,10 @@ export default ({ onDelete, onExport, onSubmit, onEmailConfirm }) => {
allErrors.email = 'Please provide a valid email.'
}
- if (!isValidPassword(form.password)) {
- allErrors.password = 'The password has to consist of at least 8 characters.'
- }
-
- if (form.password !== form.repeat || form.repeat === '') {
+ if (form.password !== form.repeat) {
allErrors.repeat = 'Passwords have to match.'
}
- if (!form.tos) {
- allErrors.tos = 'You have to accept our TOS and privacy policy in order to use our services.'
- }
-
const valid = Object.keys(allErrors).length === 0
setErrors(allErrors)
@@ -151,11 +145,21 @@ export default ({ onDelete, onExport, onSubmit, onEmailConfirm }) => {
 
<button
className="btn btn-danger"
- onClick={onDelete}
+ onClick={() => setShowModal(true)}
>
Delete account
</button>
</div>
+
+ {showModal &&
+ <Modal
+ onCancel={() => setShowModal(false)}
+ onSubmit={() => { setShowModal(false); onDelete() }}
+ submitText="Delete my account"
+ title="Delete your account?"
+ text={<>By pressing 'Delete my account' you understand, that this action is irreversible.<br/>All your data will be deleted from our servers.</>}
+ />
+ }
</div>
)
}
\ No newline at end of file