小编lee*_*oek的帖子

持久性Firebase OAuth身份验证

我正在尝试跨多个页面保持Firebase用户身份验证状态.

    $scope.loginGoogle = function() {
        console.log("Got into google login");
        ref.authWithOAuthPopup("google", function(error, authData) { 
           $scope.loggedIn = true;
           $scope.uniqueid = authData.google.displayName;
                 }, {
           remember: "sessionOnly",
           scope: "email"
        });
    };


        function checkLogin() {
           ref.onAuth(function(authData) {
             if (authData) {
                // user authenticated with Firebase
                console.log("User ID: " + authData.uid + ", Provider: " + authData.provider);
             } else {
               console.log("Nope, user is not logged in.");
             }
           });
        };
Run Code Online (Sandbox Code Playgroud)

但是,当在另一个页面中调用checkLogin函数时,即使用户已登录登录页面,也未定义authData.似乎是什么问题?

javascript angularjs firebase firebase-security angularfire

0
推荐指数
1
解决办法
856
查看次数