Skip to content

Conversation

@FBagdeli
Copy link
Collaborator

No description provided.

@aws-amplify-eu-west-2
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-47.d1ytr8ocn5wsgw.amplifyapp.com


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'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

const handleRegister = async (email, password, setErrors) => {
try {
const validatedEmail = validationEmail(email)
if(validatedEmail !== true) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if(!validatedEmail)

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'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would return true or false for this function and just display 1 error message

throw new Error(validatedEmail)
}
const validatedPassword = validationPassword(password)
if(validatedPassword !== 'ValidPassword') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!validatedPassword

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'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return true

@FBagdeli FBagdeli requested a review from Hamada-AB July 19, 2024 12:10
MyrtheDullaart
MyrtheDullaart previously approved these changes Jul 19, 2024
@FBagdeli FBagdeli removed the request for review from Hamada-AB July 19, 2024 12:16

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.'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put these errors in a utils/errors.js file so they're not scattered around the app

const emailErrorMessage = "Please enter a valid email"

try {
const validatedEmail = validationEmail(email)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the formatting here looks wrong

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.'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's put these in utils/errors.js

const emailErrorMessage = "Please enter a valid email"

try {
const validatedEmail = validationEmail(email)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting doesn't look correct

localStorage.setItem('token', token)
navigate('/')
}
// localStorage.setItem('token', token)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove commented code

const onChange = (e) => {
const { name, value } = e.target;
setFormData({ ...formData, [name]: value });
setErrors('')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use null as a default value

value={formData.password}
onChange={onChange}
name="password"
label={"Password *"}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check the formatting here - it doesn't look right

const { onRegister } = useAuth();
const [formData, setFormData] = useState({ email: "", password: "" });

const [errors, setErrors] = useState('')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use null as a default value

const onChange = (e) => {
const { name, value } = e.target;
setFormData({ ...formData, [name]: value });
setErrors('')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use null as a default value

if(res.status === 'fail') {
throw new Error(res.data.error)
}
return await login(email, password)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for this await

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants