我正在使用 ionic 和 firebase,但我的 View 登录遇到问题。
登录 View 始终显示为已通过身份验证,但在此 View 中用户尚未登录
我需要做什么才能显示未经身份验证的此 View ?因为用户尚未登录
PS:我正在使用 Facebook 社交身份验证。
.controller('BeforeLoginCtrl', function($scope, $state, $rootScope, $firebaseAuth, Auth) {
/*$scope.login = function() {
$state.go('login');
};
$scope.signUp = function() {
$state.go('signup');
};*/
Auth.$onAuth(function(authData){
if (authData === null) {
console.log("No autheticathed");
} else {
console.log("Authenticated");
/*$state.go('tab.dash');*/
}
$scope.authData = authData;
});
$scope.loginFacebook = function(){
Auth.$authWithOAuthRedirect("facebook").then(function(authData) {
}).catch(function(error) {
if (error.code === 'TRANSPORT_UNAVAILABLE') {
Auth.$authWithOAuthpopup("facebook").then(function(authData){
});
} else {
console.log(error);
}
});
};
})
.factory('Auth', function($firebaseAuth) {
var endpoint = "https://<NAME>.firebaseio.com/users";
var usersRef = new Firebase(endpoint);
return $firebaseAuth(usersRef);
});
最佳答案
如果 Auth.$onAuth(function(authData)
为您提供身份验证数据,您可以非常确定用户实际上已通过身份验证。
请记住,Firebase 会“记住”页面转换之间的身份验证状态。这在幕后透明地发生,您无需为其编写任何代码。
如果您想强制用户注销,请调用$unauth()
。
关于javascript - 身份验证在 ionic 和 Firebase 中始终处于事件状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35351505/