AngularFire2 Authentication Error: First argument "email" must be a valid string
AngularFire2 Authentication Error: First argument "email" must be a valid string
我正在尝试使用 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 );
}
NgModule
const firebaseAuthConfig = {
provider: AuthProviders.Password,
method: AuthMethods.Password
}
@NgModule({
imports: [
BrowserModule,
routing,
HttpModule,
JsonpModule,
FormsModule,
AngularFireModule.initializeApp(firebaseConfig, firebaseAuthConfig)
af.auth.login()
的签名是一个具有两个属性的对象:
// Email and password
af.auth.login({
email: 'email@example.com',
password: 'password',
},
{
provider: AuthProviders.Password,
method: AuthMethods.Password,
})
https://github.com/angular/angularfire2/blob/master/docs/5-user-authentication.md
... if you're using username and password, then you'll have to call af.auth.login() with the user's credentials.
af.auth.login({ email: 'email', password: 'pass' });
我正在尝试使用 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 );
}
NgModule
const firebaseAuthConfig = {
provider: AuthProviders.Password,
method: AuthMethods.Password
}
@NgModule({
imports: [
BrowserModule,
routing,
HttpModule,
JsonpModule,
FormsModule,
AngularFireModule.initializeApp(firebaseConfig, firebaseAuthConfig)
af.auth.login()
的签名是一个具有两个属性的对象:
// Email and password
af.auth.login({
email: 'email@example.com',
password: 'password',
},
{
provider: AuthProviders.Password,
method: AuthMethods.Password,
})
https://github.com/angular/angularfire2/blob/master/docs/5-user-authentication.md
... if you're using username and password, then you'll have to call af.auth.login() with the user's credentials.
af.auth.login({ email: 'email', password: 'pass' });