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 'email confirmation request' and 'GDPR report' functionality

Blaumaus6e3016ab0c46
diff --git a/src/pages/UserSettings/UserSettings.container.jsx b/src/pages/UserSettings/UserSettings.container.jsx
index f3da4e427..5ab8efaa3 100644
--- a/src/pages/UserSettings/UserSettings.container.jsx
+++ b/src/pages/UserSettings/UserSettings.container.jsx
@@ -4,6 +4,9 @@ import { useDispatch } from 'react-redux'
import { authActions } from 'actions/auth'
import { errorsActions } from 'actions/errors'
import { alertsActions } from 'actions/alerts'
+import { getCookie, setCookie } from 'utils/cookie'
+import { confirmEmail, exportUserData } from 'api'
+
import UserSettings from './UserSettings'
export default () => {
@@ -19,8 +22,14 @@ export default () => {
)
}
- const onExport = () => {
- // TODO
+ const onExport = async () => {
+ try {
+ await exportUserData()
+ // TODO: Use cookies to make sure user is not able to request more than 1 request per day
+ dispatch(alertsActions.accountUpdated('The GDPR data report has been sent to your email address'))
+ } catch (e) {
+ dispatch(errorsActions.updateProfileFailed(e))
+ }
}
const onSubmit = (data) => {
@@ -41,8 +50,24 @@ export default () => {
);
}
- const onEmailConfirm = () => {
- // TODO
+ const onEmailConfirm = async (errorCallback) => {
+ if (getCookie('confirmation_timeout')) {
+ dispatch(errorsActions.updateProfileFailed('An email has already been sent, check your mailbox or try again in a few minutes'))
+ return
+ }
+
+ try {
+ const res = await confirmEmail()
+
+ if (res) {
+ setCookie('confirmation_timeout', true, 600)
+ dispatch(alertsActions.accountUpdated('An account confirmation link has been sent to your email'))
+ } else {
+ errorCallback('Unfortunately, you\'ve ran out of your email confirmation requests.\nPlease make sure you are able to receive e-mails and check your SPAM folder again for messages.\nYou may try to use a different email address or contact our customer support service.')
+ }
+ } catch (e) {
+ dispatch(errorsActions.updateProfileFailed(e))
+ }
}
return (
diff --git a/src/pages/UserSettings/UserSettings.jsx b/src/pages/UserSettings/UserSettings.jsx
index cbef316eb..6cd8a1e7d 100644
--- a/src/pages/UserSettings/UserSettings.jsx
+++ b/src/pages/UserSettings/UserSettings.jsx
@@ -18,6 +18,7 @@ export default ({ onDelete, onExport, onSubmit, onEmailConfirm }) => {
const [errors, setErrors] = useState({})
const [beenSubmitted, setBeenSubmitted] = useState(false)
const [showModal, setShowModal] = useState(false)
+ const [error, setError] = useState('')
useEffect(() => {
validate()
@@ -128,7 +129,7 @@ export default ({ onDelete, onExport, onSubmit, onEmailConfirm }) => {
{user?.isActive || (
<div className="mt-4">
- <button className="btn btn-link" onClick={onEmailConfirm}>
+ <button className="btn btn-link" onClick={() => onEmailConfirm(setError)}>
<Mailbox color="#007bff" size="24" className="mr-2" />
Didn't receive a link to confirm the email address? Request a new one!
</button>
@@ -157,7 +158,15 @@ export default ({ onDelete, onExport, onSubmit, onEmailConfirm }) => {
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.</>}
+ text={'By pressing \'Delete my account\' you understand, that this action is irreversible.\nAll your data will be deleted from our servers.'}
+ />
+ }
+ {error &&
+ <Modal
+ onSubmit={() => { setError('') }}
+ submitText="Got it"
+ title="Error"
+ text={error}
/>
}
</div>