我正在尝试为新用户创建一个注册页面。注册后,应立即将数据直接发送到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;
答案 0 :(得分:1)
该错误来自Firebase身份验证,您可以通过以下方式调用该错误:
static void miniMaxSum(int[] arr) {
long min = 0, max = 0, sum = 0;
min = arr[0];
max = min;
sum = min;
for (int i = 1; i < arr.length; i++) {
sum += arr[i];
if (arr[i] < min) {
min = arr[i];
}
if (arr[i] > max) {
max = arr[i];
}
}
System.out.print((sum - max) + " " + (sum - min));
}
firebase.auth().createUserWithEmailAndPassword("galbeedmok@gmail.com","gem")
少于6个字符。
答案 1 :(得分:0)
大家好,这是我设置默认值的组合
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>