📈 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!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Display password strength meter on the signup page
Blue Mousee4b1eaaf4176
diff --git a/web/app/pages/Auth/Signup/Signup.tsx b/web/app/pages/Auth/Signup/Signup.tsxindex 7264c047a..ccf40093c 100644--- a/web/app/pages/Auth/Signup/Signup.tsx+++ b/web/app/pages/Auth/Signup/Signup.tsx@@ -32,6 +32,7 @@ import type { SignupActionData } from '~/routes/signup'import Button from '~/ui/Button'import Checkbox from '~/ui/Checkbox'import Input from '~/ui/Input'+import PasswordStrength from '~/ui/PasswordStrength'import { Text } from '~/ui/Text'import Tooltip from '~/ui/Tooltip'import { cn, delay, openBrowserWindow } from '~/utils/generic'@@ -63,6 +64,7 @@ const Signup = () => {const [tos, setTos] = useState(false)const [checkIfLeaked, setCheckIfLeaked] = useState(true)+ const [password, setPassword] = useState('')const [isSsoLoading, setIsSsoLoading] = useState(false)@@ -300,15 +302,22 @@ const Signup = () => {disabled={isLoading}onChange={() => clearFieldError('email')}/>- <Input- name='password'- type='password'- label={t('auth.common.password')}- hint={t('auth.common.hint', { amount: MIN_PASSWORD_CHARS })}- error={getFieldError('password')}- disabled={isLoading}- onChange={() => clearFieldError('password')}- />+ <div className='space-y-2'>+ <Input+ name='password'+ type='password'+ label={t('auth.common.password')}+ hint={t('auth.common.hint', { amount: MIN_PASSWORD_CHARS })}+ error={getFieldError('password')}+ disabled={isLoading}+ value={password}+ onChange={(e) => {+ setPassword(e.target.value)+ clearFieldError('password')+ }}+ />+ <PasswordStrength password={password} />+ </div>{/* Hidden fields for checkbox values since Headless UI Checkbox doesn't submit natively */}<input type='hidden' name='tos' value={tos ? 'true' : 'false'} /><inputdiff --git a/web/app/ui/PasswordStrength.tsx b/web/app/ui/PasswordStrength.tsxindex 23666653c..5687f83df 100644--- a/web/app/ui/PasswordStrength.tsx+++ b/web/app/ui/PasswordStrength.tsx@@ -3,6 +3,7 @@ import { useMemo } from 'react'import { useTranslation } from 'react-i18next'import { InfoIcon } from '@phosphor-icons/react'import Tooltip from './Tooltip'+import { MIN_PASSWORD_CHARS } from '~/utils/validator'interface PasswordStrengthProps {password: string@@ -23,8 +24,7 @@ const calculateStrength = (password: string): StrengthLevel => {let score = 0- if (password.length >= 8) score += 1- if (password.length >= 12) score += 1+ if (password.length >= 8) score += 2if (/[a-z]/.test(password)) score += 1if (/[A-Z]/.test(password)) score += 1if (/[0-9]/.test(password)) score += 1@@ -109,7 +109,9 @@ const PasswordStrength = ({ password, className }: PasswordStrengthProps) => {{currentConfig.label}</span><Tooltip- text={t('auth.passwordStrength.hint')}+ text={t('auth.passwordStrength.hint', {+ amount: MIN_PASSWORD_CHARS,+ })}tooltipNode={<InfoIcon className='size-4 cursor-help text-gray-400 dark:text-gray-500' />}diff --git a/web/public/locales/en.json b/web/public/locales/en.jsonindex fee1aae7f..eb6b8d37c 100644--- a/web/public/locales/en.json+++ b/web/public/locales/en.json@@ -818,7 +818,7 @@"fair": "Fair","good": "Good","strong": "Strong",- "hint": "Use 12+ characters with uppercase, lowercase, numbers, and symbols for a strong password."+ "hint": "Use {{amount}}+ characters with uppercase, lowercase, numbers, and symbols for a strong password."}},"profileSettings": {