![](/img/trans.png)
[英]I/flutter (16908): [firebase_auth/invalid-email] The email address is badly formatted
[英]Firebase Authentication "auth/invalid-email" and "The email address is badly formatted."
我正在尝试使用 Angular 和 Ionic 4 将 Firebase 登录/注册实施到我的应用程序中。我的帐户注册正常,但忘记了密码,我可以在我的 firebase 控制台中看到这些帐户。 我遇到的问题是当我尝试登录我创建的那个帐户时。 在开发人员控制台中,我得到https://imgur.com/a/WzRiwtn :
code: "auth/invalid-email"
message: "The email address is badly formatted."
它说问题出在我的 tab3.page.ts:22
这是该页面的代码
import { Component } from '@angular/core';
import { AlertController } from '@ionic/angular';
import { LoadingController, ToastController } from '@ionic/angular';
import { Router } from '@angular/router';
import { AngularFireAuth } from '@angular/fire/auth';
@Component({
selector: 'app-tab3',
templateUrl: 'tab3.page.html',
styleUrls: ['tab3.page.scss']
})
export class Tab3Page {
email: string = '';
password: string = '';
error: string = '';
constructor(private fireauth: AngularFireAuth,
private router: Router,
private toastController: ToastController,
public loadingController: LoadingController,
public alertController: AlertController) {
}
async openLoader() {
const loading = await this.loadingController.create({
message: 'Please Wait ...',
duration: 2000
});
await loading.present();
}
async closeLoading() {
return await this.loadingController.dismiss();
}
login() {
this.fireauth.auth.signInWithEmailAndPassword(this.email, this.password)
.then(res => {
if (res.user) {
console.log(res.user);
this.router.navigate(['/home']);
}
})
.catch(err => {
console.log(`login failed ${err}`);
this.error = err.message;
});
}
async presentToast(message, show_button, position, duration) {
const toast = await this.toastController.create({
message: message,
showCloseButton: show_button,
position: position,
duration: duration
});
toast.present();
}
}
自周五以来,我一直在盯着这个看,尝试了多种不同的在线方法和指南,我尝试的每一种方法都出现了这个错误,如果有任何帮助,我们将不胜感激。 此代码来自以下https://enappd.com/blog/email-authentication-with-firebase-in-ionic-4/38/教程,甚至查看他的 github 并完全遵循它我仍然会遇到这个问题。
从您在此处显示的内容来看,电子邮件的初始值是空字符串:
email: string = '';
而且,据我所知,它永远不会改变价值。 因此,您将一个空字符串传递给signInWithEmailAndPassword
,这是无效的。
将“”更改为空。
最好还是更新到
const [email, setEmail] = useState(null);
Firebase 身份验证“auth/invalid-email”和“email 地址格式错误。”
使用 email 格式,例如:
test@test.com
test123@gmail.com
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.