Conversation
|
This pull request is automatically being deployed by Amplify Hosting (learn more). |
src/context/auth.js
Outdated
|
|
||
| if(password.length < 1) return 'Password is required' | ||
| if(password.length < minLength ) return 'Password should be at least 8 characters long' | ||
| if(password.length > 24) return 'Password should be less than 24 characters' |
There was a problem hiding this comment.
Probably wait for the database changes, if this is required surely could be used, but for right now, i guess this is not supposed to be added.
src/context/auth.js
Outdated
| const handleRegister = async (email, password, setErrors) => { | ||
| try { | ||
| const validatedEmail = validationEmail(email) | ||
| if(validatedEmail !== true) { |
There was a problem hiding this comment.
if(!validatedEmail)
src/context/auth.js
Outdated
| if(!hasUppercase) return 'Password should have at least one uppercase letter' | ||
| if(!hasNumber) return 'Password should have at least one number' | ||
| if(!hasSpecialCharacter) return 'Password should have at least one special character' | ||
| return 'ValidPassword' |
There was a problem hiding this comment.
I would return true or false for this function and just display 1 error message
src/context/auth.js
Outdated
| throw new Error(validatedEmail) | ||
| } | ||
| const validatedPassword = validationPassword(password) | ||
| if(validatedPassword !== 'ValidPassword') { |
There was a problem hiding this comment.
!validatedPassword
src/context/auth.js
Outdated
| if(!hasUppercase) return 'Password should have at least one uppercase letter' | ||
| if(!hasNumber) return 'Password should have at least one number' | ||
| if(!hasSpecialCharacter) return 'Password should have at least one special character' | ||
| return 'ValidPassword' |
src/context/auth.js
Outdated
|
|
||
| const handleLogin = async (email, password, setErrors) => { | ||
|
|
||
| const passwordRequirments = 'Password must be at least 8 characters long and include at least one uppercase letter, one number, and one special character.' |
There was a problem hiding this comment.
Let's put these errors in a utils/errors.js file so they're not scattered around the app
src/context/auth.js
Outdated
| const emailErrorMessage = "Please enter a valid email" | ||
|
|
||
| try { | ||
| const validatedEmail = validationEmail(email) |
src/context/auth.js
Outdated
| navigate("/verification") | ||
| } | ||
| const handleRegister = async (email, password, setErrors) => { | ||
| const passwordRequirments = 'Password must be at least 8 characters long and include at least one uppercase letter, one number, and one special character.' |
src/context/auth.js
Outdated
| const emailErrorMessage = "Please enter a valid email" | ||
|
|
||
| try { | ||
| const validatedEmail = validationEmail(email) |
src/context/auth.js
Outdated
| localStorage.setItem('token', token) | ||
| navigate('/') | ||
| } | ||
| // localStorage.setItem('token', token) |
src/pages/login/index.js
Outdated
| const onChange = (e) => { | ||
| const { name, value } = e.target; | ||
| setFormData({ ...formData, [name]: value }); | ||
| setErrors('') |
src/pages/login/index.js
Outdated
| @@ -38,10 +40,11 @@ const Login = () => { | |||
| label={"Password *"} | |||
There was a problem hiding this comment.
check the formatting here - it doesn't look right
src/pages/register/index.js
Outdated
| const { onRegister } = useAuth(); | ||
| const [formData, setFormData] = useState({ email: "", password: "" }); | ||
|
|
||
| const [errors, setErrors] = useState('') |
src/pages/register/index.js
Outdated
| const onChange = (e) => { | ||
| const { name, value } = e.target; | ||
| setFormData({ ...formData, [name]: value }); | ||
| setErrors('') |
src/service/apiClient.js
Outdated
| if(res.status === 'fail') { | ||
| throw new Error(res.data.error) | ||
| } | ||
| return await login(email, password) |
43bf1f9
No description provided.