1

發生網絡錯誤(例如超時,連接中斷或無法訪問的主機)。使用Firebase API登錄時出現超時錯誤

每當我嘗試登錄時總會發生此錯誤。

我的JS代碼:

firebase.auth().signInWithEmailAndPassword(emailId, password).then(function (userData) { 
      usersRef.child(userData.uid).once("value", function (userSnap) { 
       var usersSnap = userSnap.val(); 
       /* 
       * Record login attempt to firebase 
       */ 
       if (userSnap) { 
        authlogRef.child(userData.uid).once('value', function (userLogSnap) { 
        userLogSnap = userLogSnap.val(); 
        // Initial login count 
        var loginCount = userLogSnap && userLogSnap.loginCount || 0; 
        // timestamp for current login 
        var timestamp = Date.now(); 
        // log data to update 
        var data = userLogSnap || {}; 
        //If no timestamps -> First login attempt, so timestamps -> [] 
        if (!data.timestamps) { 
        data['timestamps'] = [] 
        } 
        // push current timestamp for current login 
        data.timestamps.push(timestamp) 
        // increment login count 
        data['loginCount'] = loginCount + 1; 
        // set data to end point 
        authlogRef 
         .child(userData.uid) 
         .set(data) 
         .then(function() { 
         callback(null, usersSnap); 
         }) 
        }) 
       } 
      }).catch(function (error) { 
       var errorCode = error.code; 
       var errorMessage = error.message; 
       if (errorCode == 'auth/invalid-email') { 
        var msg = 'Email id is not Valid'; 
        callback(msg); 
       } else if (errorCode == 'auth/user-disabled') { 
        var msg = 'User is in disable state'; 
        callback(msg); 
       } else if (errorCode == 'auth/user-not-found') { 
        var msg = 'User not found'; 
        callback(msg); 
       } else if (errorCode == 'auth/wrong-password') { 
        var msg = 'Invalid Password'; 
        callback(msg); 
       } else if (errorCode == 'auth/network-request-failed') { 
        var msg = 'Network Error'; 
        callback(msg); 
       } else { 
        callback("error:" + errorMessage); 
       } 
      }); 
}) 

有時候,我得到超時錯誤。但我不能指出什麼是錯的。

+0

嘿@ankit,你可以檢查網絡控制檯,並提供什麼是超時的細節,因爲這可能發生的原因很多。 – bojeil

+0

@bojeil感謝您的回覆,錯誤越來越多的客戶computer.I沒有任何access.In在我的系統中正常working.Very罕見的情況下,我收到此錯誤 –

回答

0

我剛剛證實,如果用戶在瀏覽器中安裝了noscript(或者可能是其他任何腳本阻止擴展),則會發生此錯誤。如果身份驗證適用於大多數用戶,但其他人正在收到此錯誤消息,則可能是問題的根源。

將您使用的任何域(包括相關的OAuth域)和/或禁用其腳本攔截器的用戶列入白名單,可以解決問題。

相關問題