-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Issue: The Login.jsx component sends requests to the server even if the password is too short or fields are improperly formatted.
Solution: Add client-side checks to provide immediate feedback via toast notifications before the network request is initiated.
File Path: Imagify/client/src/components/Login.jsx
const onSubmitHandler = async (e) => {
e.preventDefault();
// Front-end validation
if (password.length < 8) {
return toast.error("Password must be at least 8 characters");
}
try {
if (state === 'Login') {
const { data } = await axios.post(backendUrl + '/api/user/login', { email, password });
// ... handle login
} else {
const { data } = await axios.post(backendUrl + '/api/user/register', { name, email, password });
// ... handle register
}
} catch (error) {
toast.error(error.message);
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels