【发布时间】:2018-09-07 23:44:14
【问题描述】:
我正在开发一个 ionic 项目,我使用 firebase 作为后端,并且正在构建一个注册和登录表单。每当我注册时,代码都运行良好。当我尝试使用“signInWithEmailAndPassword”检索它时,我收到以下错误。电子邮件地址的 Firebase 格式错误。首次创建帐户时登录成功。但是使用相同的电子邮件和密码登录后会出现错误。
import { Component, ViewChild} from '@angular/core';
import { IonicPage, NavController, AlertController, NavParams } from 'ionic-angular';
import { AngularFireAuth } from 'angularfire2/auth';
import { HomePage } from '../home/home';
@IonicPage()
@Component({
selector: 'page-signin',
templateUrl: 'signin.html',
})
export class SigninPage {
@ViewChild('email') email;
@ViewChild('password') password;
constructor(public alertCon: AlertController, public afAuth: AngularFireAuth, public navCtrl: NavController, public navParams: NavParams) {
}
ionViewDidLoad() {
console.log('ionViewDidLoad SigninPage');
}
alert(title, message){
this.alertCon.create({
title: title,
subTitle: message,
buttons: ['OK']
}).present();
}
userSignin(){
this.afAuth.auth.signInWithEmailAndPassword(this.email.value, this.password.value)
.then(data=>{
console.log('loged in');
this.navCtrl.setRoot(HomePage);
this.alert('WELCOME', 'You are loged in');
})
.catch(error=>{
console.log('Error', error)
this.alert('ERROR!', 'password or Email is wrong');
});
}
}
【问题讨论】:
-
您用来登录用户的代码在哪里?
-
对不起!!我的错误..我编辑了帖子。
标签: angular firebase ionic-framework firebase-authentication