Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Password Validation in Frontend #1

Open
ethanfebs opened this issue Mar 1, 2019 · 2 comments
Open

Password Validation in Frontend #1

ethanfebs opened this issue Mar 1, 2019 · 2 comments

Comments

@ethanfebs
Copy link
Collaborator

Make sure that the users' input for "password" and "repeat password" match in frontend without needing to submit.

@amulya
Copy link
Collaborator

amulya commented Mar 6, 2019

I have a suggestion, we'll test tomorrow
if (password != passwordRepeat) { alert("Passwords do not match"); console.error( "An error occured while making the request: Passwords do not match" ); }

@amulya
Copy link
Collaborator

amulya commented Mar 6, 2019

`import Axios from "axios";
import React from "react";

handleSubmit = event => {
  event.preventDefault();

  const email = {
    email: this.state.email
  };

  const password = {
    password: this.state.password
  };

  const passwordRepeat = {
    passwordReact: this.state.passwordRepeat
  };

  if (password != passwordRepeat) {
    alert("Passwords do not match");
    console.error(
      "An error occured while making the request: Passwords do not match"
    );
  } else {
    Axios.post(`/signup`, { email, password })
      .then(res => {
        console.log(email);
        console.log(password);
        // check status code

        // if successful re-route to profile
        if (res.data.statusCode === 200) {
          // *** remember to set status code in backend ***
          this.props.history.push({
            pathname: "/profile",
            state: { data: parsedData }
          });
        } else {
          // if not successful, return alert
          alert("Validation error occurred. " + response.data.body);
          console.log("Error " + res.data.statusCode);
        }
      })
      .catch(err => {
        console.error("An error occured while making the request");
      });
  }
};`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants