我有一个通过电子邮件和密码登录用户的操作:
export class LoginWithCredentials {
static readonly type = '[Auth] Login With Credentials';
}
每当提交登录表单时,我都会发送此操作:
onSubmitLogin() {
this.store.dispatch(LoginWithCredentials);
}
操作处理程序从状态中获取电子邮件和密码并调用firebase.auth().signInWithEmailAndPassword
,如下所示:
@Action(LoginWithCredentials)
loginWithCredentials({getState}: StateContext<AuthStateModel>) {
const {email, password} = getState().forms.login.model;
this.afAuth.auth.signInWithEmailAndPassword(email, password)
.catch(err => console.log(err)); // Should console.log on error
console.log('Should print something');
}
由于某种原因,catch
被忽略了console.log
,应该打印的东西也被忽略了。
我尝试在州外运行此方法,它似乎有效。虽然,我想把这个逻辑放到我的行动中。
PS:
如果我使用signInWithPopup(provider)
而不是signInWithEmailAndPassword
,那么它将起作用(但这不是我需要的)。