如何处理Firebase许可,否认了例外



是否有任何方法可以避免在控制台上的允许_DEDIED异常转储。我不想在控制台上看到该例外,而是想优雅地处理它。我尝试了Follownig,但似乎没有起作用。我也尝试了.onauth(),但这也不能阻止这种情况。

var ref = new Firebase(<My firebase root url>),
 ref.on("value", function(snapshot) {
     console.log("No errors.");
 }, function(err) {
     console.log("Something is wrong. "+err);
 });
Something is wrong. Error: permission_denied: Client doesn't have permission to access the desired data.
SearchCtrl.js:22 User Not Authenticated..Redirecting to Sign In Page...
ionic.bundle.js:19532 Error: permission_denied: Client doesn't have permission to access the desired data.
    at Error (native)
    at J (http://localhost:8100/lib/firebase/firebase.js:120:48)
    at Object.J (http://localhost:8100/lib/firebase/firebase.js:200:378)
    at http://localhost:8100/lib/firebase/firebase.js:185:3
    at vh.h.Hd (http://localhost:8100/lib/firebase/firebase.js:189:104)
    at jh.Hd (http://localhost:8100/lib/firebase/firebase.js:180:364)
    at bh.jh.Da.uh.t [as tg] (http://localhost:8100/lib/firebase/firebase.js:178:281)
    at eh (http://localhost:8100/lib/firebase/firebase.js:172:464)
    at WebSocket.bh.open.va.onmessage (http://localhost:8100/lib/firebase/firebase.js:171:245)(anonymous function) @ ionic.bundle.js:19532c.$$error @ angularfire.min.js:12(anonymous function) @ angularfire.min.js:12(anonymous function) @ angularfire.min.js:12forEach @ ionic.bundle.js:8248g @ angularfire.min.js:12(anonymous function) @ ionic.bundle.js:24148completeOutstandingRequest @ ionic.bundle.js:12830(anonymous function) @ ionic.bundle.js:13210
ionic.bundle.js:19532 destroy called for FirebaseArray: https://fixmycars.firebaseio.com/customers
ionic.bundle.js:19532 TypeError: Cannot read property '$$error' of null
    at angularfire.min.js:12
    at angularfire.min.js:12
    at Object.forEach (ionic.bundle.js:8248)
    at g (angularfire.min.js:12)
    at ionic.bundle.js:24148
    at completeOutstandingRequest (ionic.bundle.js:12830)
    at ionic.bundle.js:13210(anonymous function) @ ionic.bundle.js:19532$get @ ionic.bundle.js:16482(anonymous function) @ ionic.bundle.js:24151completeOutstandingRequest @ ionic.bundle.js:12830(anonymous function) @ ionic.bundle.js:13210

解析错误和/或创建匹配规则以处理您要处理的所有错误。将操作器放在当前结构中的其他语句中。

var ref = new Firebase(<My firebase root url>),
ref.on("value", function(snapshot) {
    if(snapshot.exists()){
        /*Update dom or kick of async method to mount snapshot*/
    }else{
        app.$.errorToast.text = 'Snapshot does not exist';
        app.$.errorToast.show();
    }
    console.log("Did I forget to handle an error");
}, function(err) {
    /*Compare "err" to your rules and handle as needed here*/
    console.log("Something is wrong. "+err);
}); 

在代码中的任何地方,您都尝试完成不允许的" .on"函数的操作,将触发和处理上面单个CodeBlock中所定义的。

向客户提供良好的分辨率消息,例如"当前用户不允许访问,获得访问联系admin和请求用户ID添加到许可组{myrefmeta.permgroup}"。我考虑过的一个选项是维护另一个分支,该分支描述了权限或在基本节点中添加分支的公共访问的"描述符",以提供安全详细信息。这是用户的知识和与您合作的树的不适当

将能够消除此错误。

如果用户注销并且无法清除缓存,则您的参考事件将再次触发。发生这种情况时,您应该注意清除缓存并完成完整的重新加载。清除缓存后,强迫浏览器的刷新可以通过刷新来进行。

在此代码块上方,错误在Ref.on中处理,Ref.on将永远不会接触到快照或更新DOM的呼叫。通过在错误处理程序中调用清理方法,您可以安装一个空的快照,重置您的参考文献和禁用无法可用的功能。

对于我的目的而言,要等到需要许可才能从用户请求它并创建便利性功能" ReferenceCheck",这是最佳的,您可以使用此功能根据需要启动身份验证和参考创建。这将充当"用户酶"的初始方法,该用例的清理将与此相称。

似乎您自己在控制台上添加了允许的异常转储。请勿在错误处理程序函数中添加控制台登录的" err",例如console.log("有问题"。 err);

最新更新