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!

more improvements

Blue Mouse054fff09a2ee
diff --git a/public/locales/en.json b/public/locales/en.json
index 7771bea70..49d434a20 100644
--- a/public/locales/en.json
+++ b/public/locales/en.json
@@ -1,6 +1,9 @@
{
"apiNotifications": {
- "leakedPassword": "The provided password is leaked, please use another one"
+ "somethingWentWrong": "Something went wrong, please try again",
+ "emailRegistered": "A user with this email already exists",
+ "leakedPassword": "The provided password is leaked, please use another one",
+ "rateLimitHit": "Too many requests, please try again later"
},
"common": {
"features": "Features",
diff --git a/src/pages/Auth/Signup/BasicSignup.jsx b/src/pages/Auth/Signup/BasicSignup.jsx
index cbd9495a4..d8ba84c56 100644
--- a/src/pages/Auth/Signup/BasicSignup.jsx
+++ b/src/pages/Auth/Signup/BasicSignup.jsx
@@ -1,13 +1,16 @@
import React, { memo, useState, useEffect } from 'react'
import { useDispatch } from 'react-redux'
import { authActions } from 'redux/actions/auth'
-import { useTranslation } from 'react-i18next'
+import { useTranslation, Trans } from 'react-i18next'
import Input from 'ui/Input'
import Button from 'ui/Button'
+import Checkbox from 'ui/Checkbox'
+import Tooltip from 'ui/Tooltip'
import {
isValidEmail, isValidPassword, MIN_PASSWORD_CHARS,
} from 'utils/validator'
+import { HAVE_I_BEEN_PWNED_URL } from 'redux/constants'
const BasicSignup = () => {
const { t } = useTranslation('common')
@@ -18,6 +21,7 @@ const BasicSignup = () => {
repeat: '',
tos: true,
keep_signedin: true,
+ checkIfLeaked: true,
})
const [validated, setValidated] = useState(false)
const [errors, setErrors] = useState({})
@@ -27,7 +31,7 @@ const BasicSignup = () => {
const onSubmit = (data) => {
if (!isLoading) {
setIsLoading(true)
- dispatch(authActions.signupAsync(data, () => {
+ dispatch(authActions.signupAsync(data, t, () => {
setIsLoading(false)
}))
}
@@ -38,11 +42,12 @@ const BasicSignup = () => {
}, [form]) // eslint-disable-line
const handleInput = (event) => {
- const { name, value } = event.target
+ const t = event.target
+ const value = t.type === 'checkbox' ? t.checked : t.value
setForm(form => ({
...form,
- [name]: value,
+ [t.name]: value,
}))
}
@@ -108,6 +113,31 @@ const BasicSignup = () => {
onChange={handleInput}
error={beenSubmitted && errors.repeat}
/>
+ <div className='flex mt-4'>
+ <Checkbox
+ checked={form.checkIfLeaked}
+ onChange={handleInput}
+ name='checkIfLeaked'
+ id='checkIfLeaked'
+ label={t('auth.common.checkLeakedPassword')}
+ />
+ <Tooltip
+ className='ml-2'
+ text={(
+ <Trans
+ t={t}
+ i18nKey='auth.common.checkLeakedPasswordDesc'
+ components={{
+ // eslint-disable-next-line jsx-a11y/anchor-has-content
+ db: <a href={HAVE_I_BEEN_PWNED_URL} className='font-medium text-indigo-400 hover:underline hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-500' />,
+ }}
+ values={{
+ database: 'haveibeenpwned.com',
+ }}
+ />
+ )}
+ />
+ </div>
<Button className='w-full flex justify-center' type='submit' loading={isLoading} primary giant>
{t('auth.signup.create')}
</Button>
diff --git a/src/pages/Auth/Signup/Signup.container.jsx b/src/pages/Auth/Signup/Signup.container.jsx
index 439e02ce9..76dafe0e5 100644
--- a/src/pages/Auth/Signup/Signup.container.jsx
+++ b/src/pages/Auth/Signup/Signup.container.jsx
@@ -3,8 +3,8 @@ import { authActions } from 'redux/actions/auth'
import Signup from './Signup'
const mapDispatchToProps = (dispatch) => ({
- signup: (data, callback) => {
- dispatch(authActions.signupAsync(data, callback))
+ signup: (data, t, callback) => {
+ dispatch(authActions.signupAsync(data, t, callback))
},
})
diff --git a/src/pages/Auth/Signup/Signup.jsx b/src/pages/Auth/Signup/Signup.jsx
index daecb2520..4818ec60e 100644
--- a/src/pages/Auth/Signup/Signup.jsx
+++ b/src/pages/Auth/Signup/Signup.jsx
@@ -8,13 +8,12 @@ import { withAuthentication, auth } from 'hoc/protected'
import routes from 'routes'
import Input from 'ui/Input'
import Checkbox from 'ui/Checkbox'
-import Button from 'ui/Button'
import Tooltip from 'ui/Tooltip'
+import Button from 'ui/Button'
import {
isValidEmail, isValidPassword, MIN_PASSWORD_CHARS,
} from 'utils/validator'
-
-const HAVE_I_BEEN_PWNED_URL = 'https://haveibeenpwned.com/passwords'
+import { HAVE_I_BEEN_PWNED_URL } from 'redux/constants'
const Signup = ({ signup }) => {
const { t } = useTranslation('common')
@@ -38,7 +37,7 @@ const Signup = ({ signup }) => {
const onSubmit = data => {
if (!isLoading) {
setIsLoading(true)
- signup(data, () => {
+ signup(data, t, () => {
setIsLoading(false)
})
}
diff --git a/src/redux/actions/auth/index.js b/src/redux/actions/auth/index.js
index 734e41204..a9ece40ef 100644
--- a/src/redux/actions/auth/index.js
+++ b/src/redux/actions/auth/index.js
@@ -77,11 +77,11 @@ export const authActions = {
}
},
- signupAsync(data, callback = () => { }) {
+ signupAsync(data, t, callback = () => { }) {
return {
type: types.SIGNUP_ASYNC,
payload: {
- data, callback,
+ data, callback, t,
},
}
},
diff --git a/src/redux/constants/index.js b/src/redux/constants/index.js
index ce21b9c11..631ddf879 100644
--- a/src/redux/constants/index.js
+++ b/src/redux/constants/index.js
@@ -50,6 +50,7 @@ export const LS_THEME_SETTING = 'colour-theme'
export const DONATE_URL = 'https://ko-fi.com/andriir'
export const FIREFOX_ADDON_URL = 'https://addons.mozilla.org/en-US/firefox/addon/swetrix/'
export const CHROME_EXTENSION_URL = 'https://chrome.google.com/webstore/detail/swetrix/glbeclfdldjldjonfnpnembfkhphmeld'
+export const HAVE_I_BEEN_PWNED_URL = 'https://haveibeenpwned.com/passwords'
export const isSelfhosted = Boolean(process.env.REACT_APP_SELFHOSTED)
diff --git a/src/redux/sagas/auth/workers/signup.js b/src/redux/sagas/auth/workers/signup.js
index 1cf6dfde9..181e3ba32 100644
--- a/src/redux/sagas/auth/workers/signup.js
+++ b/src/redux/sagas/auth/workers/signup.js
@@ -6,17 +6,20 @@ import UIActions from 'redux/actions/ui'
import { setAccessToken } from 'utils/accessToken'
import { signup } from 'api'
-export default function* signupWorder({ payload: { data: rawData, callback } }) {
+export default function* signupWorder({ payload: { data: rawData, callback, t } }) {
try {
const { repeat, ...data } = rawData
const response = yield call(signup, data)
+ console.log(response)
+
yield put(authActions.signupSuccess(response.user))
yield call(setAccessToken, response.access_token)
yield put(UIActions.loadProjects())
callback(true)
} catch (error) {
- yield put(errorsActions.signupFailed(error.message || (typeof error === 'string' ? error : error[0])))
+ const message = error.message || (typeof error === 'string' ? error : error[0])
+ yield put(errorsActions.signupFailed(t([`apiNotifications.${message}`, 'apiNotifications.somethingWentWrong'])))
callback(false)
} finally {
yield put(authActions.finishLoading())