removing zxcvvbn for now

This commit is contained in:
2025-10-15 15:44:29 -05:00
parent a3675c2585
commit 3781646b7f
9 changed files with 6206 additions and 6215 deletions

View File

@@ -32,8 +32,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.22.3",
"simplebar-react": "^3.2.5",
"zxcvbn": "^4.4.2"
"simplebar-react": "^3.2.5"
},
"devDependencies": {
"@iconify/react": "^4.1.1",
@@ -6048,12 +6047,6 @@
"dependencies": {
"tslib": "2.3.0"
}
},
"node_modules/zxcvbn": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/zxcvbn/-/zxcvbn-4.4.2.tgz",
"integrity": "sha512-Bq0B+ixT/DMyG8kgX2xWcI5jUvCwqrMxSFam7m0lAf78nf04hv6lNCsyLYdyYTrCVMqNDY/206K7eExYCeSyUQ==",
"license": "MIT"
}
}
}

View File

@@ -6,7 +6,7 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build:beta": "tsc && vite build --mode beta",
"build:beta": "vite build --mode beta",
"build:prod": "tsc && vite build --mode production",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
@@ -38,8 +38,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.22.3",
"simplebar-react": "^3.2.5",
"zxcvbn": "^4.4.2"
"simplebar-react": "^3.2.5"
},
"devDependencies": {
"@iconify/react": "^4.1.1",

View File

@@ -1,6 +1,5 @@
import React from 'react';
import zxcvbn from 'zxcvbn';
//import zxcvbn from '@zxcvbn-ts/core';
import { Box, LinearProgress, Typography } from '@mui/material';
interface PasswordStrengthCheckerProps {
@@ -8,7 +7,7 @@ interface PasswordStrengthCheckerProps {
}
const PasswordStrengthChecker: React.FC<PasswordStrengthCheckerProps> = ({ password }) => {
const strength = password ? zxcvbn(password).score : 0;
//const strength = password ? zxcvbn(password).score : 0;
const getStrengthLabel = () => {
switch (strength) {

View File

@@ -113,9 +113,9 @@ const AttorneyProfile = ({ account }: ProfileProps): ReactElement => {
onSave={handleSaveAttorneyProfile}
/>
<Box sx={{ mt: 4 }}>
{/*<Box sx={{ mt: 4 }}>
<ChangePasswordCard />
</Box>
</Box>*/}
</Container>
);
};

View File

@@ -1,151 +1,151 @@
import {
Alert,
Box,
Button,
Card,
CardContent,
CardHeader,
Divider,
Grid,
LinearProgress,
TextField,
Typography,
} from '@mui/material';
import { axiosInstance } from 'axiosApi';
import { useState } from 'react';
import zxcvbn from 'zxcvbn';
// import {
// Alert,
// Box,
// Button,
// Card,
// CardContent,
// CardHeader,
// Divider,
// Grid,
// LinearProgress,
// TextField,
// Typography,
// } from '@mui/material';
// import { axiosInstance } from 'axiosApi';
// import { useState } from 'react';
// import zxcvbn from '@zxcvbn-ts/core';
const ChangePasswordCard = () => {
const [currentPassword, setCurrentPassword] = useState('');
const [newPassword, setNewPassword] = useState('');
const [confirmPassword, setConfirmPassword] = useState('');
const [passwordStrength, setPasswordStrength] = useState(0);
const [message, setMessage] = useState<{ type: 'success' | 'error'; text: string } | null>(null);
const [errors, setErrors] = useState<{ [key: string]: string }>({});
// const ChangePasswordCard = () => {
// const [currentPassword, setCurrentPassword] = useState('');
// const [newPassword, setNewPassword] = useState('');
// const [confirmPassword, setConfirmPassword] = useState('');
// const [passwordStrength, setPasswordStrength] = useState(0);
// const [message, setMessage] = useState<{ type: 'success' | 'error'; text: string } | null>(null);
// const [errors, setErrors] = useState<{ [key: string]: string }>({});
const handlePasswordChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const password = e.target.value;
setNewPassword(password);
const strength = zxcvbn(password).score;
setPasswordStrength(strength);
};
// const handlePasswordChange = (e: React.ChangeEvent<HTMLInputElement>) => {
// const password = e.target.value;
// setNewPassword(password);
// const strength = zxcvbn(password).score;
// setPasswordStrength(strength);
// };
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
setErrors({});
setMessage(null);
// const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
// e.preventDefault();
// setErrors({});
// setMessage(null);
if (newPassword !== confirmPassword) {
setErrors({ confirmPassword: 'Passwords do not match' });
return;
}
// if (newPassword !== confirmPassword) {
// setErrors({ confirmPassword: 'Passwords do not match' });
// return;
// }
if (passwordStrength < 2) {
setErrors({ newPassword: 'Password is too weak' });
return;
}
// if (passwordStrength < 2) {
// setErrors({ newPassword: 'Password is too weak' });
// return;
// }
try {
await axiosInstance.post('/auth/password/change/', {
old_password: currentPassword,
new_password: newPassword,
});
setMessage({ type: 'success', text: 'Password updated successfully!' });
setCurrentPassword('');
setNewPassword('');
setConfirmPassword('');
setPasswordStrength(0);
} catch (error: any) {
setMessage({ type: 'error', text: 'Error updating password.' });
if (error.response && error.response.data) {
setErrors(error.response.data);
}
}
};
// try {
// await axiosInstance.post('/auth/password/change/', {
// old_password: currentPassword,
// new_password: newPassword,
// });
// setMessage({ type: 'success', text: 'Password updated successfully!' });
// setCurrentPassword('');
// setNewPassword('');
// setConfirmPassword('');
// setPasswordStrength(0);
// } catch (error: any) {
// setMessage({ type: 'error', text: 'Error updating password.' });
// if (error.response && error.response.data) {
// setErrors(error.response.data);
// }
// }
// };
const passwordStrengthColor = () => {
switch (passwordStrength) {
case 0:
case 1:
return 'error';
case 2:
return 'warning';
case 3:
case 4:
return 'success';
default:
return 'grey';
}
};
// const passwordStrengthColor = () => {
// switch (passwordStrength) {
// case 0:
// case 1:
// return 'error';
// case 2:
// return 'warning';
// case 3:
// case 4:
// return 'success';
// default:
// return 'grey';
// }
// };
return (
<Card>
<CardHeader title="Change Password" />
<Divider />
<CardContent>
<form onSubmit={handleSubmit}>
<Grid container spacing={2}>
{message && (
<Grid item xs={12}>
<Alert severity={message.type}>{message.text}</Alert>
</Grid>
)}
<Grid item xs={12}>
<TextField
fullWidth
label="Current Password"
type="password"
value={currentPassword}
onChange={(e) => setCurrentPassword(e.target.value)}
error={!!errors.old_password}
helperText={errors.old_password}
required
/>
</Grid>
<Grid item xs={12}>
<TextField
fullWidth
label="New Password"
type="password"
value={newPassword}
onChange={handlePasswordChange}
error={!!errors.new_password}
helperText={errors.new_password}
required
/>
<Box sx={{ width: '100%', mt: 1 }}>
<LinearProgress
variant="determinate"
value={(passwordStrength / 4) * 100}
color={passwordStrengthColor()}
/>
<Typography variant="caption" color="textSecondary">
{['Very Weak', 'Weak', 'Fair', 'Good', 'Strong'][passwordStrength]}
</Typography>
</Box>
</Grid>
<Grid item xs={12}>
<TextField
fullWidth
label="Confirm New Password"
type="password"
value={confirmPassword}
onChange={(e) => setConfirmPassword(e.target.value)}
error={!!errors.confirmPassword}
helperText={errors.confirmPassword}
required
/>
</Grid>
<Grid item xs={12}>
<Button type="submit" variant="contained" color="primary">
Change Password
</Button>
</Grid>
</Grid>
</form>
</CardContent>
</Card>
);
};
// return (
// <Card>
// <CardHeader title="Change Password" />
// <Divider />
// <CardContent>
// <form onSubmit={handleSubmit}>
// <Grid container spacing={2}>
// {message && (
// <Grid item xs={12}>
// <Alert severity={message.type}>{message.text}</Alert>
// </Grid>
// )}
// <Grid item xs={12}>
// <TextField
// fullWidth
// label="Current Password"
// type="password"
// value={currentPassword}
// onChange={(e) => setCurrentPassword(e.target.value)}
// error={!!errors.old_password}
// helperText={errors.old_password}
// required
// />
// </Grid>
// <Grid item xs={12}>
// <TextField
// fullWidth
// label="New Password"
// type="password"
// value={newPassword}
// onChange={handlePasswordChange}
// error={!!errors.new_password}
// helperText={errors.new_password}
// required
// />
// <Box sx={{ width: '100%', mt: 1 }}>
// <LinearProgress
// variant="determinate"
// value={(passwordStrength / 4) * 100}
// color={passwordStrengthColor()}
// />
// <Typography variant="caption" color="textSecondary">
// {['Very Weak', 'Weak', 'Fair', 'Good', 'Strong'][passwordStrength]}
// </Typography>
// </Box>
// </Grid>
// <Grid item xs={12}>
// <TextField
// fullWidth
// label="Confirm New Password"
// type="password"
// value={confirmPassword}
// onChange={(e) => setConfirmPassword(e.target.value)}
// error={!!errors.confirmPassword}
// helperText={errors.confirmPassword}
// required
// />
// </Grid>
// <Grid item xs={12}>
// <Button type="submit" variant="contained" color="primary">
// Change Password
// </Button>
// </Grid>
// </Grid>
// </form>
// </CardContent>
// </Card>
// );
// };
export default ChangePasswordCard;
// export default ChangePasswordCard;

View File

@@ -236,9 +236,9 @@ const PropertyOwnerProfile = ({ account }: ProfileProps): ReactElement => {
setMessage={setMessage}
/>
<Box sx={{ mt: 4 }}>
{/*<Box sx={{ mt: 4 }}>
<ChangePasswordCard />
</Box>
</Box>*/}
<Divider sx={{ my: 4 }} />

View File

@@ -166,9 +166,9 @@ const VendorProfile = ({ account }: ProfileProps): ReactElement => {
onSave={handleSaveVendorProfile}
/>
<Box sx={{ mt: 4 }}>
{/*<Box sx={{ mt: 4 }}>
<ChangePasswordCard />
</Box>
</Box>*/}
<Divider sx={{ my: 4 }} />

View File

@@ -89,7 +89,7 @@ const ResetPassword = (): ReactElement => {
),
}}
/>
<PasswordStrengthChecker password={password} />
{/*<PasswordStrengthChecker password={password} />*/}
</FormControl>
<FormControl variant="standard" fullWidth>
<InputLabel shrink htmlFor="confirm-password">

View File

@@ -246,7 +246,7 @@ const SignUp = (): ReactElement => {
),
}}
/>
<PasswordStrengthChecker password={password} />
{/*<PasswordStrengthChecker password={password} />*/}
</FormControl>
<FormControl variant="standard" fullWidth>
<InputLabel shrink htmlFor="password">