admin管理员组

文章数量:1291720

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

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

Share Improve this question edited Nov 22, 2016 at 15:47 Frank van Puffelen 600k85 gold badges889 silver badges859 bronze badges asked Nov 22, 2016 at 14:38 Nevin Nevin 3751 gold badge7 silver badges18 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

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.

本文标签: javascriptGetting Firebase Current User InfoStack Overflow