SyncUser.current multiple values crash



I moved to a new Realm in the cloud.

For authentication, I am using Google with a token (jwt)

When I try to log in using the token for my user, my app crashes when I call SyncUser.current because Realm is finding the old user from the old realm that I moved from - as well as the user on the current Realm.

It is here where things go bad…

+ (RLMSyncUser *)currentUser {
    NSArray *allUsers = [[RLMSyncManager sharedManager] _allUsers];
    if (allUsers.count > 1) {
        @throw RLMException(@"+currentUser cannot be called if more that one valid, logged-in user exists.");
    return allUsers.firstObject;

If I print out the users info, I see this value:

Printing description of (*( (std::__1::string *)0x107e403c8)):
(std::__1::string) m_server_url = ""

Printing description of (*( (std::__1::string *)0x10883c648)):
(std::__1::string) m_server_url = ""

How can I force the user from the “old” Realm to be logged out, or in some way make them go away?



I was able to fix the crash by uninstalling the app from the device and then re-installing it.

Definitely not ideal, but I can get past this issue.


You can get all users by calling SyncUser.all and then call user.logOut() for each user you don’t want to keep around.