mbeps / next_discussion_platform

Full Stack Website for Forum Discussion Platform using Next.JS and Firebase
https://circus-discussion.vercel.app
MIT License
49 stars 11 forks source link

BUG: Improve password validation #15

Closed mbeps closed 1 year ago

mbeps commented 1 year ago

Describe the bug

When entering an inappropriate password (too short), the system does not display any errors and there is no clean message informing the user whether the account has been created or not.

Reproducing the bug

  1. Try to sign up using email and password
  2. Enter password that is too short new1

Expected behavior

Screenshots

Screenshot from 2023-02-14 19-03-29

Platforms

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context

Severity:

mbeps commented 1 year ago

The snippet bellow can be inserted into onSubmit in src/components/Modal/Auth/Signup.tsx. This will check whether:

mbeps commented 1 year ago

Separating each requirement would be better as it would allow the user to know exactly which requirement was not met. The current implementation is confusing as the user may not know immediately why the requirement was not met. Screenshot from 2023-02-14 19-56-40

    if (signUpForm.password.length < 8) {
      setError("Password must be at least 8 characters long");
      return;
    }
    if (!/\d/.test(signUpForm.password)) {
      setError("Password must contain at least 1 number");
      return;
    }
    if (!/[!@#$%^&*(),.?":{}|<>]/.test(signUpForm.password)) {
      setError("Password must contain at least 1 special character");
      return;
    }
    if (!/[A-Z]/.test(signUpForm.password)) {
      setError("Password must contain at least 1 capital letter");
      return;
    }
mbeps commented 1 year ago

16 Fixed