<commit_before>import React, { Component } from 'react';
import classNames from 'classnames';
import { Link } from 'react-router-dom';
import PropTypes from 'prop-types';
import { Alert, Button, Checkbox, ControlLabel, Form,
         HelpBlock, FormControl, FormGroup } from 'react-bootstrap';

import { product, userRegex } from 'config';

import { passwordPassRegex } from 'helpers/utils';
import { TempUsage } from 'containers';
import { LoaderIcon } from 'components/icons';

import './style.scss';


class UserSignup extends Component {
  static propTypes = {
    available: PropTypes.bool,
    cb: PropTypes.func,
    checkUser: PropTypes.func,
    checkedUsername: PropTypes.string,
    result: PropTypes.string,
    errors: PropTypes.object,
    submitting: PropTypes.bool,
    success: PropTypes.bool,
    user: PropTypes.object,
    userCheck: PropTypes.bool,
    validUsername: PropTypes.bool
  };

  constructor(props) {
    super(props);

    this.state = {
      moveTemp: true,
      toColl: 'New Collection',
      username: '',
      name: '',
      email: '',
      announce_mailer: false,
      password: '',
      confirmpassword: ''
    };
  }

  save = (evt) => {
    evt.preventDefault();
    const { user } = this.props;
    const { announce_mailer, username, name,
            email, password, confirmpassword, moveTemp, toColl } = this.state;

    if (!password || !confirmpassword) {
      this.setState({ missingPw: true });
    }

    if (username && this.validateUsername() === 'success' &&
       password && confirmpassword && this.validatePassword() === null && email) {
      // core fields to send to server
      let data = { username, email, password, confirmpassword };

      if (announce_mailer) {
        data = { ...data, announce_mailer };
      }

      if (name) {
        data = { ...data, full_name: name };
      }

      // check for anon usage
      if (user.get('anon') && user.get('num_collections') > 0) {
        data = { ...data, moveTemp, toColl };<commit_msg>Add missingPw flag check on update, confirm valid email before submission (#660)<commit_after>import React, { Component } from 'react';
import classNames from 'classnames';
import { Link } from 'react-router-dom';
import PropTypes from 'prop-types';
import { Alert, Button, Checkbox, ControlLabel, Form,
         HelpBlock, FormControl, FormGroup } from 'react-bootstrap';

import { product, userRegex } from 'config';

import { passwordPassRegex } from 'helpers/utils';
import { TempUsage } from 'containers';
import { LoaderIcon } from 'components/icons';

import './style.scss';


class UserSignup extends Component {
  static propTypes = {
    available: PropTypes.bool,
    cb: PropTypes.func,
    checkUser: PropTypes.func,
    checkedUsername: PropTypes.string,
    result: PropTypes.string,
    errors: PropTypes.object,
    submitting: PropTypes.bool,
    success: PropTypes.bool,
    user: PropTypes.object,
    userCheck: PropTypes.bool,
    validUsername: PropTypes.bool
  };

  constructor(props) {
    super(props);

    this.state = {
      moveTemp: true,
      toColl: 'New Collection',
      username: '',
      name: '',
      email: '',
      announce_mailer: false,
      password: '',
      confirmpassword: ''
    };
  }

  componentDidUpdate() {
    const { confirmpassword, missingPw, password } = this.state;

    // clear missing confirm password error
    if(missingPw && password && confirmpassword) {
      this.setState({ missingPw: false});
    }
  }

  save = (evt) => {
    evt.preventDefault();
    const { user } = this.props;
    const {
      announce_mailer,
      confirmpassword,
      email,
      moveTemp,
      name,
      password,
      toColl,
      username
    } = this.state;

    if (!password || !confirmpassword) {
      this.setState({ missingPw: true });
    }

    if (username && this.validateUsername() === 'success' &&
       password && confirmpassword && this.validatePassword() === null &&
       email && this.validateEmail() === null) {
      // core fields to send to server
      let data = { username, email, password, confirmpassword };

      if (announce_mailer) {
        data = { ...data, announce_mailer };
      }

      if (name) {
        data = { ...data, full_name: name };
      }

      // check for anon usage
      if (user.get('anon') && user.get('num_collections') > 0) {
        data = { ...data, moveTemp, toColl };
{'fraction_non_alphanumeric': 0.13173381620642824, 'fraction_numerical': 0.0011317338162064282, 'mean_word_length': 2.7736976942783946, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7587245', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1318, 'n_words': 342}