update password strength test + use autofocus prop for password input
This commit is contained in:
@@ -5,8 +5,8 @@ import { LinearProgress, Stack, Typography, Box } from '@mui/material';
|
||||
|
||||
type TStrength = 'weak' | 'medium' | 'strong' | 'init';
|
||||
|
||||
const strong = /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*])(?=.{8,})/;
|
||||
const medium = /^(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,})/;
|
||||
const strong = /^(?=.*[a-z])(?=.*[0-9])(?=.*[!@#$%^&*])(?=.{8,})/;
|
||||
const medium = /^(((?=.*[a-z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[0-9])))(?=.{6,})/;
|
||||
|
||||
const colorMap = {
|
||||
init: 'inherit' as 'inherit',
|
||||
|
||||
@@ -38,8 +38,9 @@ export const PasswordInput: React.FC<{
|
||||
error?: string;
|
||||
label: string;
|
||||
showForgottenPassword?: boolean;
|
||||
autoFocus?: boolean;
|
||||
onUpdatePassword: (password: string) => void;
|
||||
}> = ({ password, label, error, showForgottenPassword, onUpdatePassword }) => {
|
||||
}> = ({ password, label, error, showForgottenPassword, autoFocus, onUpdatePassword }) => {
|
||||
const [showPassword, setShowPassword] = useState(false);
|
||||
|
||||
return (
|
||||
@@ -51,7 +52,7 @@ export const PasswordInput: React.FC<{
|
||||
value={password}
|
||||
onChange={(e) => onUpdatePassword(e.target.value)}
|
||||
type={showPassword ? 'input' : 'password'}
|
||||
autoFocus
|
||||
autoFocus={autoFocus}
|
||||
InputProps={{
|
||||
endAdornment: (
|
||||
<IconButton onClick={() => setShowPassword((show) => !show)}>
|
||||
|
||||
@@ -43,7 +43,12 @@ export const CreatePassword = ({ onSkip, onNext }: { page: TPages; onNext: () =>
|
||||
<FormControl fullWidth>
|
||||
<Stack spacing={2}>
|
||||
<>
|
||||
<PasswordInput password={password} onUpdatePassword={(pswd) => setPassword(pswd)} label="Password" />
|
||||
<PasswordInput
|
||||
password={password}
|
||||
onUpdatePassword={(pswd) => setPassword(pswd)}
|
||||
label="Password"
|
||||
autoFocus
|
||||
/>
|
||||
<PasswordStrength password={password} onChange={(isStrong) => setIsStrongPassword(isStrong)} />
|
||||
</>
|
||||
<PasswordInput
|
||||
|
||||
@@ -44,6 +44,7 @@ export const ExistingAccount: React.FC<{
|
||||
password={password}
|
||||
onUpdatePassword={(pswd) => setPassword(pswd)}
|
||||
label="Password"
|
||||
autoFocus
|
||||
error={error}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -19,6 +19,7 @@ export const SignInPassword = ({ onPrev }: { page: TPages; onPrev: () => void })
|
||||
password={password}
|
||||
onUpdatePassword={(pswd) => setPassword(pswd)}
|
||||
error={error}
|
||||
autoFocus
|
||||
/>
|
||||
<Button
|
||||
variant="contained"
|
||||
|
||||
Reference in New Issue
Block a user