首页 > 解决方案 > 如何在 Firebase 登录/注册过程中提示用户提供更多信息?

问题描述

我正在使用 firebaseUI 工具集来允许用户登录我的应用程序。一旦他们登录,我还使用 firebase.auth().onAuthStateChanged 方法将它们重定向到主应用程序。

我想做的是,在登录过程中......如果他们是新用户,提示他们使用显示名称(以覆盖第 3 方提供者提供的任何名称)。

现在,一旦他们登录,他们就会被重定向到应用程序..我如何才能拥有一个流畅的工作流程来提供一个模态 /screen 以允许他们在继续使用应用程序之前创建一个显示名称,这并不明显。

是否有关于如何在首次登录过程中捕获/提示其他信息的推荐最佳实践,然后我会将其存储在我的 firebase /users 集合中?

现在它只会自动重定向到主应用程序。

    componentDidMount() {
    //console.log(this.props.isLoading)
    firebase.auth().onAuthStateChanged(user => {
        if(user) {

            this.props.setUser(user);
            this.props.history.push('/');

        } 


  callbacks : {
    signInSuccessWithAuthResult: function(authResult, redirectUrl) {
    var user = authResult.user;
    var credential = authResult.credential;
    var isNewUser = authResult.additionalUserInfo.isNewUser;
    var providerId = authResult.additionalUserInfo.providerId;
    var operationType = authResult.operationType;

    if(isNewUser)
    {
        //prompt user to enter a displayName to use with the application
    }
    // Do something with the returned AuthResult.
    // Return type determines whether we continue the redirect automatically
    // or whether we leave that to developer to handle.
    return true;
  },

},

标签: reactjsfirebase-authenticationfirebaseui

解决方案


推荐阅读