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域)和/或禁用其脚本拦截器的用户列入白名单,可以解决问题。

相关问题