I am using single-sign on with Facebook in my application and have been attempting to logout but have been unsuccessful with the posted solutions. I am currently getting an error stating cannot read property of "logout". Thanks!
angular.module('starter.controllers', [])
.controller('AppCtrl', function($scope, $ionicModal, $timeout,$state) {
var ref = new Firebase("https://example.firebaseio.com");
$scope.loginFacebook = function(){
if(ionic.Platform.isWebView()){
$cordovaFacebook.login(["public_profile", "email"]).then(function(success){
console.log(success);
ref.authWithOAuthToken("facebook", success.authResponse.accessToken, function(error, authData) {
if (error) {
console.log('Firebase login failed!', error);
} else {
console.log('Authenticated successfully with payload:', authData);
return $state.go('app.gyms');
}
});
}, function(error){
console.log(error);
});
}
else {
ref.authWithOAuthPopup("facebook", function(error, authData) {
if (error) {
console.log("Login Failed!", error);
} else {
console.log("Authenticated successfully with payload:", authData);
console.log("Username:" + authData.facebook.displayName);
console.log("Profile Image:" + authData.facebook.profileImageURL);
$scope.displayName = authData.facebook.displayName;
$scope.profileImageURL = authData.facebook.profileImageURL;
$scope.modal.hide();
$scope.isLoggedIn = function(){
return true;
};
$scope.isLoggedIn();
}
});
}
};
$scope.logOut = function() {
ref.unauth();
return $state.go('app.gyms');
};
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.