我正在为vuejs应用程序在Firebase Web上使用Google登录。 Firebase的google登录提供了两个选项-redirect和popup登录。成功登录后,我想将用户重定向到特定页面。这适用于弹出方法,但具有重定向功能,它可以登录用户但返回到登录页面。我需要设置某种属性才能使其正常工作吗?我的代码段如下:
firebase.auth().signInWithPopup(provider).then(function(result) {// This gives you a Google access Token. You can use it to access the Google API. var token = result.credential.accessToken;// The signed-in user info. var user = result.user; that.navToLogin(); //---> this works with signInWithPopup});firebase.auth().signInWithRedirect(provider).then(function(result) { //user gets signed in but it does not redirect to a new page that.navToLogin(); //---> this does not work});//Below didn't work either:firebase.auth().signInWithRedirect(provider);firebase.auth().getRedirectResult().then(function(result) { if (result.credential) { // This gives you a Google access Token. You can use it to access the Google API. var token = result.credential.accessToken; that.navToLogin(); //---> this does not work } // The signed-in user info. var user = result.user;})
这似乎是重复的。您可以在此处获得有关重定向行为的解释:
Firebase Google signInWithRedirect not redirecting to specified page on successful authentication
