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!

limit password length

Blue Mouse59cc02dafae7
diff --git a/public/locales/en.json b/public/locales/en.json
index 49d434a20..adcb3f8d9 100644
--- a/public/locales/en.json
+++ b/public/locales/en.json
@@ -127,6 +127,7 @@
"xCharsError": "The password has to consist of at least {{amount}} characters.",
"noMatchError": "Passwords have to match.",
"badEmailError": "Please provide a valid email.",
+ "passwordTooLong": "The provided password is too long, maximum length is 100 characters",
"tosError": "You have to accept our TOS and privacy policy in order to use our services.",
"email": "Email",
"signin": "Sign in",
diff --git a/src/pages/Auth/CreateNewPassword/CreateNewPassword.jsx b/src/pages/Auth/CreateNewPassword/CreateNewPassword.jsx
index 487786537..9812c6510 100644
--- a/src/pages/Auth/CreateNewPassword/CreateNewPassword.jsx
+++ b/src/pages/Auth/CreateNewPassword/CreateNewPassword.jsx
@@ -1,6 +1,7 @@
import React, { useState, useEffect, memo } from 'react'
import { Link, useHistory, useParams } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
+import _size from 'lodash/size'
import { createNewPassword } from 'api'
import { withAuthentication, auth } from 'hoc/protected'
@@ -77,6 +78,10 @@ const CreateNewPassword = ({
allErrors.repeat = t('auth.common.noMatchError')
}
+ if (_size(form.password) > 100) {
+ allErrors.password = t('auth.common.passwordTooLong')
+ }
+
const valid = Object.keys(allErrors).length === 0
setErrors(allErrors)
@@ -107,7 +112,7 @@ const CreateNewPassword = ({
id='repeat'
type='password'
label={t('auth.common.repeat')}
- value={form.password}
+ value={form.repeat}
placeholder={t('auth.common.password')}
className='mt-4'
onChange={handleInput}
diff --git a/src/pages/Auth/Signup/BasicSignup.jsx b/src/pages/Auth/Signup/BasicSignup.jsx
index d8ba84c56..cb13159d0 100644
--- a/src/pages/Auth/Signup/BasicSignup.jsx
+++ b/src/pages/Auth/Signup/BasicSignup.jsx
@@ -2,6 +2,7 @@ import React, { memo, useState, useEffect } from 'react'
import { useDispatch } from 'react-redux'
import { authActions } from 'redux/actions/auth'
import { useTranslation, Trans } from 'react-i18next'
+import _size from 'lodash/size'
import Input from 'ui/Input'
import Button from 'ui/Button'
@@ -76,6 +77,10 @@ const BasicSignup = () => {
allErrors.repeat = t('auth.common.noMatchError')
}
+ if (_size(form.password) > 100) {
+ allErrors.password = t('auth.common.passwordTooLong')
+ }
+
const valid = Object.keys(allErrors).length === 0
setErrors(allErrors)
diff --git a/src/pages/Auth/Signup/Signup.jsx b/src/pages/Auth/Signup/Signup.jsx
index 4818ec60e..aad157b35 100644
--- a/src/pages/Auth/Signup/Signup.jsx
+++ b/src/pages/Auth/Signup/Signup.jsx
@@ -2,6 +2,7 @@ import React, { useState, useEffect, memo } from 'react'
import { Link } from 'react-router-dom'
import PropTypes from 'prop-types'
import { useTranslation, Trans } from 'react-i18next'
+import _size from 'lodash/size'
import Title from 'components/Title'
import { withAuthentication, auth } from 'hoc/protected'
@@ -78,6 +79,10 @@ const Signup = ({ signup }) => {
allErrors.repeat = t('auth.common.noMatchError')
}
+ if (_size(form.password) > 100) {
+ allErrors.password = t('auth.common.passwordTooLong')
+ }
+
if (!form.tos) {
allErrors.tos = t('auth.common.tosError')
}