我已将this的基础知识应用到我的应用程序中,但我遇到的问题是它总是返回一个错误,指出用户已经在空的firebase上注册了电子邮件。
这是注册用户的功能:
registerUser()
{
if (this.newUser.password === this.newUser.passwordConfirm)
{
this.firebaseRef.createUser({email: this.newUser.email, password: this.newUser.password}, (error) => {
if (error) {
console.log(error);
}
});
}
else
{
console.log("Invalid passwords");
}
}
并且始终返回此错误:user-registration.component.ts:34 Error: The specified email address is already in use.(…)
。就像我说的,firebase是空的,我100%确定我用正确的URL初始化了firebase
这是我在Angular2中的注册组件
import { Component, OnInit} from '@angular/core';
import {FirebaseEventPipe} from "../firebasepipe";
import {User} from "../classes/user";
@Component({
selector: 'registration',
templateUrl: 'app/views/registration.component.html',
pipes: [FirebaseEventPipe],
})
export class RegistrationComponent implements OnInit{
private firebaseUrl: string;
private firebaseRef: Firebase;
newUser: User;
submitted = false;
constructor() {
this.firebaseUrl = "https://<<myfirebaseurl>>.firebaseio.com/";
this.firebaseRef = new Firebase(this.firebaseUrl);
}
registerUser()
{
if (this.newUser.password === this.newUser.passwordConfirm)
{
this.firebaseRef.createUser({email: this.newUser.email, password: this.newUser.password}, (error) => {
if (error) {
console.log(error);
}
});
}
else
{
console.log("Invalid passwords");
}
}
ngOnInit():any {
this.newUser = {email: '', password: '', passwordConfirm: ''}
}
// TODO: Remove this when we're done
get diagnostic() { return JSON.stringify(this.newUser); }
}