how to get current use in firebase in ionic code example
Example: how to get current use in firebase in ionic
.controller('dashCtrl', function($scope, $state, $ionicPopup, $ionicLoading, $firebaseAuth) { //library injection
var user = firebase.auth().currentUser; // code from firebase docs
var name, email, photoUrl, uid; //declare the variable
//checking the user
if (user != null) {
name = user.displayName; //fetch the name
email = user.email; // fetch the email
photoUrl = user.photoURL; // fetch
uid = user.uid; // fetch uid
//password = user.password;
// The user's ID, unique to the Firebase project. Do NOT use
// this value to authenticate with your backend server, if
// you have one. Use User.getToken() instead.
console.log(email); //log the email. success display at console
console.log(uid);
}
//logout function
$scope.logout=function(){
firebase.auth().signOut().then(function() {
console.log("Sign-out successful.");
$state.go('login');
}, function(error) {
// An error happened.
});
}
})