How do I get the current user's information in my application without using a listener like onStateChanged
? Right now I'm using:
auth.createUserWithEmailAndPassword(email,password).then(function(user){ }
to get the user info then assign it to a variable .. but when I refresh the page, the variable loses its assigned value
According to the docs using currentUser
should do the trick:
var user = firebase.auth().currentUser;
if (user) {
// User is signed in.
} else {
// No user is signed in.
}
Make a synchronous call by using $firebaseAuth
service
$firebaseAuth().$getAuth();
It will return the currently signed-in user or null
if no user is signed in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With