$auth.getAuth() returns null for anonymous user?
See original GitHub issueVersion info
Angular: 1.5.8 Firebase: 3.5.2 AngularFire: 2.1.0
Other (e.g. Node, browser, operating system) (if applicable): Win 10 Firefox 49.0.2
Test case
Don’t have time at the moment
Steps to reproduce
- auth anymously.
- use following directive in resolve of route you want to disallow logged in user to view. i found here that $auth.getAuth() returns null $auth = firebaseAuth from factory:
$stateProvider
//game -> login
.state('login',{
url:'/login',
controller: 'GameLoginCtrl',
templateUrl:'views/desktop/game/login.html',
resolve: {
loadMyFiles:function($ocLazyLoad) {
return $ocLazyLoad.load({
name:'app',
files:[
'js/controllers/GameLogin.js',
'css/login.css'
]
});
},
'currentAuth': ['$q','$auth',function($q,$auth){
var u = $auth.$getAuth();
var p = $q.defer();
console.log(u); // null, but localStorage shows anonymous user.
if (u) {
return p.reject('ALREADY_AUTH');
} else {
return p.resolve();
}
}]
}
})
Expected behavior
Actual behavior
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:10
Top Results From Across the Web
$auth.getAuth() returns null for anonymous user? #875 - GitHub
auth anymously. use following directive in resolve of route you want to disallow logged in user to view. i found here that $auth.getAuth()...
Read more >$firebaseAuth().$getAuth() returns a null - Stack Overflow
to get the current user you should do this: var user = firebase.auth().currentUser; if (user) { // User is signed in. } else...
Read more >Why is my currentUser == null in Firebase Auth? - Medium
Here's an easy enough bit of code in JavaScript that checks to see if a user is signed in: const user = firebase.auth().currentUser...
Read more >Auth | JavaScript SDK | Firebase JavaScript API reference
Reference for Auth. ... The current emulator configuration (or null). ... If there is already an anonymous user signed in, that user will...
Read more >Authentication
import { getAuth, onAuthStateChanged } from "firebase/auth"; const auth ... additionalUserInfo.profile == null // You can check if the user is new or ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yup, you can do that.
$waitForSignIn()
is fulfilled with the auth state, so you can do:looks like a race condition. if i wait a while and navigate to the url without a page refresh, it shows up correctly