在这种情况下检测Firebase登录何时完成或取消

问题描述

我学习了ReactJs,现在我必须具有Firebase登录我有一个设计问题,关于如何检测Firebase selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element 何时完成。用户linkWithPopup,我的匿名用户Firebase UID将被转换为Google凭据。

Button弹出,用户选择一个要使用的Google帐户。

我必须检测该过程何时完成或中止。

这是我的代码

用户单击“按钮”以登录Google时调用方法

linkWithPopup

我遇到的问题是,由于onSocialLoginLink = provider => { const { firebase,changeUserRole } = this.props; firebase.auth.currentUser .linkWithPopup(firebase[provider]) // .linkWithRedirect(this.props.firebase[provider]) .then(changeUserRole()) .then(this.fetchSignInMethods) .catch(error => this.setState({ error })); }; 当然是异步运行的,因此changeUserRole()linkWithPopup返回之前被调用。这意味着即使用户选择中止登录,我的用户也可以从linkWithPopup获得新的注册卷。

我必须检测该过程何时完成或中止。

推荐的最佳方法是什么? 我的想法是,如果我可以检测到登录窗口失去焦点并重新获得焦点时,可以查看Firebase用户是否已将提供者更改为Google还是仍然是匿名用户?这可行吗?

enter image description here

这是处理登录changeUserRole()

Component

解决方法

如果这是问题,您可以添加一个条件来检查而不是更改角色

    const { firebase,changeUserRole } = this.props;
    firebase.auth.currentUser
        .linkWithPopup(firebase[provider])
        .then(res=>{
              if(res.credential){changeUserRole()}
         })
        .then(this.fetchSignInMethods)
        .catch(error => this.setState({ error }));
};```

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...