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!

fix: email changing

Blue Mousee98525ed58bc
diff --git a/web/app/api/index.ts b/web/app/api/index.ts
index 5d69b00e3..2fdf34037 100644
--- a/web/app/api/index.ts
+++ b/web/app/api/index.ts
@@ -244,6 +244,15 @@ export const verifyEmail = ({ id }: { id: string }) =>
throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message
})
+export const confirmChangeEmail = ({ id }: { id: string }) =>
+ api
+ .get(`v1/auth/change-email/confirm/${id}`)
+ .then((response) => response.data)
+ .catch((error) => {
+ debug('%s', error)
+ throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message
+ })
+
export const verifyShare = ({ path, id }: { path: string; id: string }) =>
api
.get(`/project/${path}/${id}`)
diff --git a/web/app/pages/Auth/ChangeEmail/index.tsx b/web/app/pages/Auth/ChangeEmail/index.tsx
new file mode 100644
index 000000000..1440f41b1
--- /dev/null
+++ b/web/app/pages/Auth/ChangeEmail/index.tsx
@@ -0,0 +1,103 @@
+import { useState, useEffect, memo } from 'react'
+import { useParams, Link } from '@remix-run/react'
+import { useTranslation } from 'react-i18next'
+import { CheckCircleIcon, XCircleIcon } from '@heroicons/react/24/solid'
+import _isString from 'lodash/isString'
+
+import { confirmChangeEmail } from 'api'
+import Loader from 'ui/Loader'
+import routes from 'utils/routes'
+
+const ChangeEmail = () => {
+ const { t } = useTranslation('common')
+ const { id } = useParams()
+ const [loading, setLoading] = useState(true)
+ const [error, setError] = useState('')
+
+ useEffect(() => {
+ setLoading(true)
+
+ if (!_isString(id)) {
+ setError(t('auth.verification.invalid'))
+ setLoading(false)
+ return
+ }
+
+ confirmChangeEmail({ id })
+ .then(() => {
+ setLoading(false)
+ })
+ .catch((reason) => {
+ setError(reason.toString())
+ setLoading(false)
+ })
+ }, [id]) // eslint-disable-line
+
+ if (loading) {
+ return (
+ <div className='min-h-page bg-gray-50 dark:bg-slate-900'>
+ <Loader />
+ </div>
+ )
+ }
+
+ if (error) {
+ return (
+ <div className='min-h-page bg-gray-50 px-4 py-16 dark:bg-slate-900 sm:px-6 sm:py-24 md:grid md:place-items-center lg:px-8'>
+ <div className='mx-auto max-w-max'>
+ <main className='sm:flex'>
+ <XCircleIcon className='h-12 w-12 text-red-400' aria-hidden='true' />
+ <div className='sm:ml-6'>
+ <div className='max-w-prose sm:border-l sm:border-gray-200 sm:pl-6'>
+ <h1 className='text-4xl font-extrabold tracking-tight text-gray-900 dark:text-gray-50 sm:text-5xl'>
+ {error}
+ </h1>
+ </div>
+ <div className='mt-8 flex space-x-3 sm:border-l sm:border-transparent sm:pl-6'>
+ <Link
+ to={routes.dashboard}
+ className='inline-flex items-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2'
+ >
+ {t('common.dashboard')}
+ </Link>
+ <Link
+ to={routes.contact}
+ className='inline-flex items-center rounded-md border border-transparent bg-indigo-100 px-4 py-2 text-sm font-medium text-indigo-700 hover:bg-indigo-200 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:bg-slate-800 dark:text-gray-50 dark:hover:bg-slate-700 dark:focus:ring-gray-50'
+ >
+ {t('notFoundPage.support')}
+ </Link>
+ </div>
+ </div>
+ </main>
+ </div>
+ </div>
+ )
+ }
+
+ return (
+ <div className='min-h-page bg-gray-50 px-4 py-16 dark:bg-slate-900 sm:px-6 sm:py-24 md:grid md:place-items-center lg:px-8'>
+ <div className='mx-auto max-w-max'>
+ <main className='sm:flex'>
+ <CheckCircleIcon className='h-12 w-12 text-green-500 dark:text-green-400' aria-hidden='true' />
+ <div className='sm:ml-6'>
+ <div className='max-w-prose sm:border-l sm:border-gray-200 sm:pl-6'>
+ <h1 className='text-4xl font-extrabold tracking-tight text-gray-900 dark:text-gray-50 sm:text-5xl'>
+ {t('auth.verification.success')}
+ </h1>
+ </div>
+ <div className='mt-8 flex space-x-3 sm:border-l sm:border-transparent sm:pl-6'>
+ <Link
+ to={routes.dashboard}
+ className='inline-flex items-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2'
+ >
+ {t('common.dashboard')}
+ </Link>
+ </div>
+ </div>
+ </main>
+ </div>
+ </div>
+ )
+}
+
+export default memo(ChangeEmail)
diff --git a/web/app/pages/UserSettings/UserSettings.tsx b/web/app/pages/UserSettings/UserSettings.tsx
index 515de9b02..bf49eb1ed 100644
--- a/web/app/pages/UserSettings/UserSettings.tsx
+++ b/web/app/pages/UserSettings/UserSettings.tsx
@@ -245,7 +245,13 @@ const UserSettings = ({
}
}
- updateUserProfileAsync(data, t('profileSettings.updated'), callback)
+ updateUserProfileAsync(data, t('profileSettings.updated'), (isSuccess: boolean) => {
+ if (isSuccess && data.email && data.email !== user.email) {
+ toast.success(t('profileSettings.emailChanged'))
+ }
+
+ callback(isSuccess)
+ })
}
useEffect(() => {
diff --git a/web/app/routes/change-email.$id.tsx b/web/app/routes/change-email.$id.tsx
index 7e4302797..35349fcc9 100644
--- a/web/app/routes/change-email.$id.tsx
+++ b/web/app/routes/change-email.$id.tsx
@@ -1,4 +1,4 @@
-import VerifyEmail from 'pages/Auth/VerifyEmail'
+import ChangeEmail from 'pages/Auth/ChangeEmail'
import type { SitemapFunction } from 'remix-sitemap'
import type { HeadersFunction } from '@remix-run/node'
import { redirect } from '@remix-run/node'
@@ -23,5 +23,5 @@ export const sitemap: SitemapFunction = () => ({
})
export default function Index() {
- return <VerifyEmail />
+ return <ChangeEmail />
}
diff --git a/web/public/locales/de.json b/web/public/locales/de.json
index 5cc71c395..b72f119c7 100644
--- a/web/public/locales/de.json
+++ b/web/public/locales/de.json
@@ -465,6 +465,7 @@
},
"profileSettings": {
"logoutAll": "Von allen Geräten abmelden",
+ "emailChanged": "To confirm the change of your email address, please click the link in the email we sent you to your new email address.",
"account": "Konto",
"general": "Allgemeine Einstellungen",
"update": "Konto aktualisieren",
diff --git a/web/public/locales/el.json b/web/public/locales/el.json
index 412e84157..65a5aa054 100644
--- a/web/public/locales/el.json
+++ b/web/public/locales/el.json
@@ -465,6 +465,7 @@
},
"profileSettings": {
"logoutAll": "Log out from all devices",
+ "emailChanged": "To confirm the change of your email address, please click the link in the email we sent you to your new email address.",
"account": "Account",
"general": "Γενικές ρυθμίσεις",
"update": "Ενημέρωση προφίλ",
diff --git a/web/public/locales/en.json b/web/public/locales/en.json
index 14ef50afd..fb48eef44 100644
--- a/web/public/locales/en.json
+++ b/web/public/locales/en.json
@@ -465,6 +465,7 @@
},
"profileSettings": {
"logoutAll": "Log out from all devices",
+ "emailChanged": "To confirm the change of your email address, please click the link in the email we sent you to your new email address.",
"account": "Account",
"general": "General settings",
"update": "Update profile",
diff --git a/web/public/locales/es.json b/web/public/locales/es.json
index a054863b8..ff7c24e0c 100644
--- a/web/public/locales/es.json
+++ b/web/public/locales/es.json
@@ -465,6 +465,7 @@
},
"profileSettings": {
"logoutAll": "Log out from all devices",
+ "emailChanged": "To confirm the change of your email address, please click the link in the email we sent you to your new email address.",
"account": "Cuenta",
"general": "General settings",
"update": "Update profile",
diff --git a/web/public/locales/pl.json b/web/public/locales/pl.json
index 123d87278..d50a37aa5 100644
--- a/web/public/locales/pl.json
+++ b/web/public/locales/pl.json
@@ -465,6 +465,7 @@
},
"profileSettings": {
"logoutAll": "Log out from all devices",
+ "emailChanged": "To confirm the change of your email address, please click the link in the email we sent you to your new email address.",
"account": "Account",
"general": "Ustawienia ogólne",
"update": "Zaktualizuj profil",
diff --git a/web/public/locales/sv.json b/web/public/locales/sv.json
index 45475443a..89767f560 100644
--- a/web/public/locales/sv.json
+++ b/web/public/locales/sv.json
@@ -465,6 +465,7 @@
},
"profileSettings": {
"logoutAll": "Log out from all devices",
+ "emailChanged": "To confirm the change of your email address, please click the link in the email we sent you to your new email address.",
"account": "Konto",
"general": "Allmänna inställningar",
"update": "Uppdatera profil",
diff --git a/web/public/locales/uk.json b/web/public/locales/uk.json
index 710212f50..351652bc5 100644
--- a/web/public/locales/uk.json
+++ b/web/public/locales/uk.json
@@ -465,6 +465,7 @@
},
"profileSettings": {
"logoutAll": "Вийти з усіх пристроїв",
+ "emailChanged": "To confirm the change of your email address, please click the link in the email we sent you to your new email address.",
"account": "Обліковий запис",
"general": "Загальні налаштування",
"update": "Оновити профіль",