-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion: logout to return a promise #583
Comments
@youpage It is worth noting that logout() is an asynchronous operation. There is an open bug against the Firebase SDK to make this return a promise. @katowulf @davideast FYI |
Yep, not a lot we can do here until the underlying SDK is fixed. There's currently no way for AngularFire to know when the action is completed either. |
IMO it made sense not to rely on What we do is bind to the Auth.. Something like: doLogin(whatever){
this.af.auth.login().then(() => {
this.af.auth.subscribe(auth => {
if(!auth) doRedirect();
}
}
}
doLogout() {
this.af.auth.logout();
} That way if the user gets logged out for whatever reason(expires, remote, etc) it redirects. We use this in kiosks that are left on for a long time.. |
Checking firebase docs I see that signOut |
The best practice here is still to monitor the auth subscription, for the reasons @DennisSmolek already noted. Looks like the SDK is working as expected and we could also return a promise here now. |
I tried to follow that best practise, but I can't get this to work properly:
When I log in for the first time everything works fine. Am I doing something wrong? |
Suggestion: logout to return a promise
Why not have FirebaseAuth.logout return a promise?
Version info
Angular: 2.0.1
Firebase: 3.4.0
AngularFire: 2.0.0-beta.5
Use case
Most of the time, if not always after logout you'll need to redirect.
Debug output
Here is what I mean: line 89
https://github.com/youpage/angular2-firebase/blob/master/src/auth/services/auth-service.ts
And the call from the Toolbar: line 26
https://github.com/youpage/angular2-firebase/blob/master/src/layout/components/toolbar.ts
Expected behavior
FirebaseAuth.logout should return a promise
Actual behavior
No returning behaviour
Thank's
P.S. Other than this, great job guys, I love it.
The text was updated successfully, but these errors were encountered: