Firebase身份验证未使用React识别我的密码



我正在尝试为新用户制作注册页面。注册后应立即将数据直接发送到Firebase数据库。问题在于,Firebase不断给我"密码必须大于6个字符"错误。我不知道为什么,因为我放了足够多的字母。

非常感谢

import React, { Component } from 'react';
import ReactDOM from 'react-dom'
import NavbarT from './UnivComp/navbar.js';
import FooterT from './UnivComp/footer.js';
import fire from './config/firebased.js';
import writeUserData from './config/rwfire.js'
import firebase from 'firebase';
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
class Apppr extends Component {
  constructor(props) {
      super(props);
      this.signup = this.signup.bind(this);
      this.state = {
        email: '',
        password: '',
        subject:'',
        location:'',
        telephone:'',
        brief:'',
        youtubevid:'',
      };
    }
    signup(e){
        e.preventDefault();
        console.log(e);
        firebase.auth().createUserWithEmailAndPassword("galbeedmok@gmail.com","gem")
        .then((res) => {
            firebase.database().ref('users/' + res.user.uid).set({
              email:   this.state.email,
              password:   this.state.password,
              subject:   this.state.subject,
              location:   this.state.location,
              telephone:   this.state.telephone,
              brief:   this.state.brief,
              youtubevid:  this.state.youtubevid,
            });
        });
}
  render() {
    const { signup } = this.props;
    return (
      <div>
      <NavbarT/>
      <form class = " clearin container  mx-auto">
        <div class="form-group pb-3">
          <label for="exampleInputEmail1"><h3>Email address</h3></label>
          <input type="email" class="form-control input-md" id="exampleInputEmail1" value={this.state.email} onChange={e => this.setState({ email: e.target.value })} aria-describedby="emailHelp" placeholder="Enter email"/>
          <small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
          </div>
      <div class="form-group pb-3">
        <label for="exampleInputPassword1"><h3>Password</h3></label>
        <input type="password" class="form-control input-md" id="exampleInputPassword1" value={this.state.password}  onChange={e => this.setState({ password: e.target.value })} placeholder="Password"/>
        {console.log(this.state.password)}
        </div>
        <div class="form-group">
        <label for="exampleFormControlSelect2 "><h3>What subjects do you tutor?</h3></label>
        <select multiple class="form-control form-control-lg" value={this.state.subject} onChange={e => this.setState({ subject : "Physics" })} id="exampleFormControlSelect2">
        <option>Physics</option>
        <option>Chemistry</option>
        <option>Human Biology</option>
        <option>Mathematics</option>
        <option>ESL</option>
        <option>English</option>
        </select>
        </div>
          <div class="mb-5 form-group pb-3 ">
            <label><h3>Where abouts are you located?</h3></label>
            <input  class="form-control input-md" value={this.state.location} onChange={e => this.setState({ location: e.target.value })} aria-describedby="emailHelp" placeholder="e.g Claremont"/>
            </div>
            <div class="form-group pb-3 ">
        <label for="example-tel-input">Telephone</label>
        <input class="form-control input-md" type="tel" placeholder="1-(555)-555-5555" id="example-tel-input" value={this.state.telephone} onChange={e => this.setState({ telephone: e.target.value })}/>
        </div>
        <div class="form-group pb-3">
    <label for="exampleTextarea"><h3>Give students a brief description of yourself.</h3></label>
    <textarea class="form-control input-md" id="exampleTextarea" rows="3" value={this.state.brief} onChange={e => this.setState({ brief: e.target.value })}></textarea>
  </div>
  <div class="form-group pb-3">
    <label for="exampleInputEmail1"><h3>A youtube video depicting your work</h3></label>
    <input  class="form-control input-md"  aria-describedby="emailHelp" placeholder="https://www.youtube.com/watch?v=ZlRObEeuuJM" value={this.state.youtubevid} onChange={e => this.setState({ youtubevid: e.target.value })}/>
    </div>
<br/>
<button onClick={console.log(this.state.password)} style={{marginLeft: '25px'}} class="btn btn-success">Signup</button>
        </form>
      <FooterT/>
      </div>
    );
  }
}
export default Apppr;

错误来自firebase身份验证,您致电以下方式:

firebase.auth().createUserWithEmailAndPassword("galbeedmok@gmail.com","gem")

"gem"比6个字符短。

嘿,这个错误是我设置默认值

的组合
    firebase.auth().createUserWithEmailAndPassword("galbeedmok@gmail.com","gem")

以及我的处理程序有故障。我已经使用了对实例的个人处理,并且已经开始工作:

      <div class="form-group pb-3">
    <label for="exampleInputPassword1"><h3>Password</h3></label>
    <input type="password" class="form-control input-md" id="exampleInputPassword1" value={this.state.password}  onChange={e => this.setState({ password: e.target.value })} placeholder="Password"/>
    {console.log(this.state.password)}
    </div>

最新更新