切换到所需的选项卡(iOS,Android也特定于语言(
我正在从事一个离子2项目,我想添加寄存器并使用Firebase auth中的电子邮件和密码创建新用户
我的register.html
页面是给定
<ion-content padding>
<form [formGroup]="registerForm" (submit)="doRegister()" novalidate>
<ion-item margin-bottom>
<ion-input
type="text"
formControlName="name" placeholder="Name"></ion-input>
</ion-item>
<ion-item margin-bottom>
<ion-input
type="email"
formControlName="email" placeholder="Email"></ion-input>
</ion-item>
<ion-item margin-bottom>
<ion-input
type="password"
formControlName="password" placeholder="Password"></ion-input>
</ion-item>
<button ion-button block type="submit">
Register
</button>
register.ts
如下
export class RegisterPage {
public registerForm;
submitAttempt: boolean = false;
loading: any;
constructor(public navCtrl: NavController, public authService: AuthProvider, public navParams: NavParams, public formBuilder: FormBuilder,public alertCtrl: AlertController, public loadingCtrl: LoadingController) {
let EMAIL_REGEXP = /^[a-z0-9!#$%&'*+/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i;
this.registerForm = formBuilder.group({
email: ['', Validators.compose([Validators.required, Validators.pattern(EMAIL_REGEXP)])],
password: ['', Validators.compose([Validators.minLength(6), Validators.required])],
name: ['', Validators.compose([Validators.minLength(6), Validators.required])]
});
}
doRegister() {
firebase.auth().createUserWithEmailAndPassword(email, password).then((auth : any) =>
{
this.navCtrl.setRoot(HomePage);
console.log(email,password);
})
.catch(function(error) {
var errorCode = error.code;
var errorMessage = error.message;
if (errorCode == 'auth/weak-password') {
alert('The password is too weak.');
} else {
alert(errorMessage);
}
console.log(error);
});
}
}
但它不会创建用户,它给我带来了错误。
There is no user record corresponding to this identifier. The user may have been deleted.
有帮助吗?
所有Firebase Ingup方法仅在身份验证选项卡下保存用户。您必须通过调用类似的设置方法
在成功注册后专门创建用户。firebase.database().ref('users/' + userId).set({
username: name,
email: email,
profile_picture : imageUrl
});
阅读有关Create&amp;的更多信息。在此处更新在Web上读取并写入数据
注意:此URL用于Firebase Web使用情况。确保从左侧Sidemenu