我正在使用Firebase
auth
处理表单中用户的身份验证,但我遇到此错误
未定义的“持久性”错误
添加时
firebase.auth().setPersistence
.
onSubmit = event => {
const { firebase } = this.props;
const { email, password, remember } = this.state;
firebase
.doSignInWithEmailAndPassword(email, password, remember)
.then(authUser => {
firebase.doEmailUpdateUser(authUser);
})
.then(() => {
this.setState({ error: null });
navigate(ROUTES.INDEX);
})
.catch(error => {
this.setState({
error,
errorOpen: true
});
});
event.preventDefault();
};
鉴于
firebase.doSignInWithEmailAndPassword(email, password, remember)
是
doSignInWithEmailAndPassword = (email, password, remember) => {
this.auth
.setPersistence(
`${
remember
? this.auth.Auth.Persistence.LOCAL
: this.auth.Auth.Persistence.SESSION
}`
)
.then(() => this.auth.signInWithEmailAndPassword(email, password));
};
this.auth = app.auth();
我错过什么了吗?我做错了什么?