简体   繁体   English

如何配置 Firebase UI 以在登录后返回上一页

[英]How to configure Firebase UI to go back to previous page after sign in

  var uiConfig = {
    signInSuccessUrl: '/',
    signInOptions: [
      // Leave the lines as is for the providers you want to offer your users.
      firebase.auth.GoogleAuthProvider.PROVIDER_ID,
      firebase.auth.FacebookAuthProvider.PROVIDER_ID,
      //firebase.auth.TwitterAuthProvider.PROVIDER_ID,
      //firebase.auth.GithubAuthProvider.PROVIDER_ID,
      firebase.auth.EmailAuthProvider.PROVIDER_ID,
      //firebase.auth.PhoneAuthProvider.PROVIDER_ID,
      //firebaseui.auth.AnonymousAuthProvider.PROVIDER_ID
    ],
      
      callbacks: {
        signInSuccessWithAuthResult: function() {
            window.history.back();
            return false;
        },
      }

I would like to configure the pre built firebase UI so that after the sign in process is completed, it goes back to the page that the user was on before signing in. (I want to use this instead of the signInSuccessUrl because if the user signed in to buy something, I don't want them redirected to a different page. I tried adding in the callback function that should allow me to not use the SignInSuccessUrl, but it isn't working. My plan was to use a callback with window.history.back(); but maybe this wouldn't work? During the firebase sign in process it appears that the browser is redirected several times, so maybe going back by one page in the history wouldn't work? Does anyone know of a better way to do this? I appreciate the help.我想配置预先构建的 firebase UI,以便在登录过程完成后,它返回到用户登录前所在的页面。(我想使用它而不是 signInSuccessUrl,因为如果用户签名在购买东西时,我不希望它们重定向到不同的页面。我尝试添加回调函数,该函数应该允许我不使用 SignInSuccessUrl,但它不起作用。我的计划是使用带有窗口的回调.history.back(); 但也许这行不通?在 firebase 登录过程中,浏览器似乎被重定向了几次,所以也许在历史记录中返回一页是行不通的?有谁知道有更好的方法来做到这一点吗?感谢您的帮助。

Your sign in success URL is set to /您的登录成功 URL 设置为 /

Instead, cut out your call back altogether and set the success URL to the URL that you want.相反,完全取消您的回调并将成功 URL 设置为您想要的 URL。

If it's a dynamic URL, you can use window.location如果是动态 URL,则可以使用 window.location

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM