learning-ionic / Chapter-8

Building a Messaging App
https://www.packtpub.com/application-development/learning-ionic
11 stars 18 forks source link

Logout does not remove online user in Firebase! #6

Open hughred22 opened 9 years ago

hughred22 commented 9 years ago

Your logout code has problem. You are missing the value to pass in $getRecord(). I change the code into follow: if (onlineUsers) { var presenceId = UserFactory.getPresenceId(); console.log ("presenceId is " + presenceId); var user = onlineUsers.$getRecord(presenceId); console.log ("User is " + user); onlineUsers.$remove(user); }

And it remove the user from online user list. But we still have a BIG ISSUE: What if user session expire? It will kick the user out but it will not delete the online user.

I want to know how you use $onAuth to deal with session expire issue. Basically I want to figure out all the best practices to deal with user login, logout, and session management with Firebase and Ionic...

arvindr21 commented 9 years ago

Take a look at: https://www.firebase.com/docs/web/libraries/angular/guide/user-auth.html#section-auth-state for session state detection.