【发布时间】:2016-10-18 21:47:02
【问题描述】:
我正在尝试使用 angularFire2 和 Firebase 为我的网络应用制作登录和注册表单。
在获取用户注册信息并将其传递到 signInWithEmailAndPassword 函数时出现错误。
signInWithEmailAndPassword failed: First argument "email" must be a valid string.
我的组件中有处理作为字符串类型的电子邮件变量的所有内容,并且它作为字符串记录到控制台,所以我不确定到底发生了什么。
我已经研究了将近 3 个小时,但找不到任何可以解决问题的方法。
模板:
<form action="" class="login">
<input type="email" name="loginEmail" id="loginEmail" placeholder="email" [(ngModel)]="signInEmail">
<input type="password" name="loginPassword" id="loginPassword" placeholder="password" [(ngModel)]="signInPassword">
<a href="#">Forgot Password?</a>
<button type="submit" (click)="login(signInEmail, signInPassword)">Sign In</button>
</form>
组件:
// Sign In
signInEmail: string;
signInPassword: string;
constructor(private _songsService: SongService, private _router: Router, public af: AngularFire) {
this.backgroundImage = '../images/main-bg.jpg';
this.logoIcon = '../images/logo-icon.png';
}
login(email, password) {
console.log('login');
this.af.auth.login( email, password );
}
Ng模块
const firebaseAuthConfig = {
provider: AuthProviders.Password,
method: AuthMethods.Password
}
@NgModule({
imports: [
BrowserModule,
routing,
HttpModule,
JsonpModule,
FormsModule,
AngularFireModule.initializeApp(firebaseConfig, firebaseAuthConfig)
【问题讨论】:
-
您可以发布您尝试登录的电子邮件吗?可能是无效的。
-
这是我自己的个人邮箱,并且是有效的邮箱。
-
你有没有在登录功能中尝试
console.log(email,password)`? -
我也尝试过其他电子邮件地址。即使是我拥有但不是我的主要帐户的其他帐户,我也会遇到同样的错误。
-
是的,我正在控制台中取回电子邮件和密码。
标签: angular firebase firebase-authentication angularfire angularfire2