Closed zeeshanz closed 4 years ago
Same happen
What is the error message you're getting when calling user.logOut
?
in my case
I am call
SyncUser.current().logOut()
but when logging in (With different account) again this exception is thrown.
java.lang.IllegalStateException: Current user is not valid if more that one valid, logged-in user exists.
This exception only happen when i am logging in with different account, for example i was logged in with some account then do log out then logging in with different account.(not happen with same account)
I tried to restart activity but same result.
I am using Google authentication with JWT.
The problem is not with logOut()
but rather with the fact you're calling SyncUser.current()
. What you can do is to either logout the current user before logging in the new one or use SyncUser.allLoggedIn()
to get all logged in users and log out everyone except the new user.
Correct, the exception thrown on SyncUser.current()
.
But this is the problem that i am call SyncUser.current().logOut()
before logging in with new user.
@bmunkholm this is Java issue and I don't really have much knowledge to debug further.
This exception should only be thrown if multiple users are logged in, but it is unclear why this has happened. Instead of calling SyncUser.current()
you can iterate over all known users by calling SyncUser.users()
instead. This should give you an idea about what the underlying cause might be.
@pavelpoley @zeeshanz Did any of you try above?
Closing due to no response. Please reopen when/if you can provide more details.
The Doc says to use
SyncUser.logOut
but it is not valid any longer. https://docs.realm.io/sync/using-synced-realms/usersYou cannot get the current user either since
SyncUser user = SyncUser.current()
fails with an exception.So at this point there really are no instructions how to logout a user and how to deal with this error:
Current user is not valid if more that one valid, logged-in user exists.