所以我使用requireAuth()
fromfirebase
来开发一个使用gulpJs
,angularJs
和Firebase
原因的网络应用程序。我对这三件事很陌生。requireAuth()
方法在我的应用程序中效果很好,在网上搜索东西,我遇到了$waitForAuth()
,我仍然无法弄清楚其中的区别。从名字上看,一个人会等待认证,但是requireAuth()
(显然也会等待对吗?)。什么时候使用最理想,$waitForAuth()
什么时候使用最理想requireAuth()
。
myApp.factory('Authentification', function($firebase, $firebaseObject, $firebaseAuth, $routeParams, $location, FIREBASE_URL){
//not posting the other parts of the code since they are not needed in this case
var ref = new Firebase(FIREBASE_URL);
var auth = $firebaseAuth(ref);
var mytempObj = {
requireAuth: function() {
return auth.$requireAuth();
},
waitAuth: function(){
return auth.$waitForAuth();
}//wait for user to be authenticated
}
return mytempObj;
}