Difference between logOut and removeUser

In the client SDKs, what’s the difference between the logOut function and the removeUser functions?

In Swift, those functions are app.currentUser.logOut() and app.currentUser.remove().

According to the doc, the remove function “logs out and destroys the session related to this user”. I’ve been using logOut until now, but I had problems with the session after that (getting invalidSession errors), so I’m guessing I need to use remove instead. But now I’m curious, in what case would you want to use logOut? In which case you don’t want to destroy the session of the logged out user?

Thanks for the clarifications.

@Jean-Baptiste_Beau The iOS docs need to get updated but they will follow the same API and design as the other SDKs, see Android here: https://docs.mongodb.com/realm/sdk/android/advanced-guides/multi-user-applications/

logOut() removes the user from the cache - so they will need to logIn again to the server to re-authenticate. remove() removes the user AND removes any data/realms downloaded/opened by the user.

@Ian_Ward Thanks for the answer. Following up on that, I’m wondering what I should do after an invalidSession error. I’ve created a new topic:

Could you please have a look? Thanks a lot.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.