SyncUser.currentUser is not cleared on log out
See original GitHub issueLogging out doesn’t seem to clear the current user. This makes it very hard to switch users. I had to manually remove the signed out user from the SyncManager user store to get sign out/switch user to work as expected. Are you supposed to have to do this manually? In the realm tasks app, the current user is ignored when switching users, which seems like a workaround too.
I am using full synchronziation for my realm if that helps
Code Sample
SyncManager.addAuthenticationListener(object:AuthenticationListener{
override fun loggedOut(user: SyncUser?) {
SyncManager.removeAuthenticationListener(this)
user?.let {
//Without this line SyncUser.currentUser() will not return null even though the user has bee
// signed out
SyncManager.getUserStore().remove(user.identity, user.authenticationUrl.toString())
}
signOutFromMyOwnAuthSystemAndRestartApp()
}
override fun loggedIn(user: SyncUser?) {}
})
SyncUser.current().logOut()
Version of Realm and tooling
Realm version(s): 5.2.0
Realm sync feature enabled: yes
Android Studio version: 3.1.3
Which Android version and device: Nexus 5x
Issue Analytics
- State:
- Created 5 years ago
- Comments:17 (6 by maintainers)
Top Results From Across the Web
Realm logOut Current user is not valid - Stack Overflow
Currently this is working only after activity restart public void logOut() { Map<String, SyncUser> all = SyncUser.all(); for (Map.
Read more >SyncUser (Realm 5.3.1) - MongoDB
public static SyncUser current(). Returns the current user that is logged in and still valid. A user is invalidated when he/she logs out...
Read more >Logout - Auth0
Log users out of Auth0 by clearing the Single Sign-on (SSO) cookie. ... It is not necessary to log the users out of...
Read more >How to Log Out User Sessions in SharePoint Online?
Requirement: Force Log Off all sessions of a user, as he lost his mobile device, which is logged-in with SharePoint Online sites.
Read more >Chapter 8: Log in, log out | Ruby on Rails Tutorial (3rd Ed.)
boolean method, which we'll now define. A user is logged in if there is a current user in the session, i.e., if current_user...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Closing as this is related to legacy sync.
As stater earlier. SyncUser.getCurrent returns null if you call it directly after log out, which is probably what the unit test is covering. But when you start the next activity it won’t be null anymore.
In my case, the workaround works good enough, which is why it is hard to prioritize producing a repro case. But without a workaround this can lead to corrupted realms, so it is severe. I’ll see if I can make time for producing a sample, but I can’t make any promises. Already spent a lot of time on this issue.