0

I use Firebase and Swift, for a custom auth with Instagram.

I have this problem now, Remove a user through dashboard, but the user is still logged in?

When I start the app, I have this listener:

Auth.auth().addStateDidChangeListener {

in which I am setting an observer:

ref.child("users/\(user.uid)").observe(.value, with: { (snapshot) in
        print(snapshot)
        ..........
    }, withCancel: { error in
        print(error)
    })

with and withCancel handlers are not executed, because user's token does not exist anymore. ( very weird IMO that even withCancel does not execute).

I have to catch this situation in code, to force a logout, like the post stated:

check whether you can read to your users area, and if there's nothing there, force a log out.

Laura Calinoiu
  • 704
  • 1
  • 8
  • 24

1 Answers1

0

I ended up reporting a bug report to Firebase. I will post the response, since it may help someone in the future.

The guys from Firebase responded this,

The behavior you have described is intended by design. A user's session persists indefinitely even if you have deleted the user from the application. To help you with this scenario, you may check on the following StackOverflow posts that might give you more information on how to handle this one.

More on this, I have insisted with the cancel block, why it did not execute:

I don’t understrand why withCancel completion handler is not called. from this:

 ref.child("users/\(user.uid)").observe(.value, with: { (snapshot) in 
     print(snapshot) 
     .......... 
     }, withCancel: { error in 
        print(error)  
     }) 

When I put breakpoints on both prints, app does not stop. So, even withCancel is not called.

The answer:

Going to your withCancel completion handler inquiry, let me just give you a bit of information here. Cancel blocks are called if the client is unauthenticated and no longer has permission to receive events. Additionally, it is also worth mentioning that cancel blocks are not called during offline mode as Firebase is designed to work well in this condition. You may check our document for further details.

Laura Calinoiu
  • 704
  • 1
  • 8
  • 24