响应中错误的电子邮件/密码上的Firebase身份验证错误消息

时间:2018-08-11 10:40:06

标签: reactjs firebase

我想在输入错误的电子邮件或密码时显示错误消息。这意味着未在Firebase中输入电子邮件?请指导我该怎么做?也许我必须在某个地方更改firebase代码?

class Login extends Component {
      constructor(props) {
        super(props);
        this.login = this.login.bind(this);
        this.handleChange = this.handleChange.bind(this);
        this.state = {
          email: '',
          password: '',
          emailError='',
          passwordError=''
        }
      }
      ksdghioerhgioerhgeroisss

      handleChange(e) {
        this.setState({ [e.target.name]: e.target.value });
      }


      login(e) {
        e.preventDefault(); 
        fire.auth().signInWithEmailAndPassword(this.state.email, this.state.password).then((u)=>{
        }).catch((error) => {
            console.log(error);
          });
      }


    render(){
        return(
            <div>
            <Navbar/>
            <div className="text-center" data-gr-c-s-loaded="true">
            <div className="container">
            <form className="form-signin">
          <div className="form-group">
           <label for="exampleInputEmail1">Email address</label>
           <input value={this.state.email} errorText={this.state.emailError} onChange={this.handleChange} type="email" name="email" className="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email" />
          </div>
           <div className="form-group">
          <label for="exampleInputPassword1">Password</label>
          <input value={this.state.password} errorText={this.state.passwordError} onChange={this.handleChange} type="password" name="password" className="form-control" id="exampleInputPassword1" placeholder="Enter Password" />
          </div>
          <button type="submit" onClick={this.login} class="btn btn-primary">Login</button>
         <small id="emailHelp" className="form-text text-muted">@2017-2018</small>

          </form>
          </div>
          </div>

0 个答案:

没有答案