{"action":"created","issue":{"url":"https://api.github.com/repos/realm/realm-java/issues/3866","repository_url":"https://api.github.com/repos/realm/realm-java","labels_url":"https://api.github.com/repos/realm/realm-java/issues/3866/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-java/issues/3866/comments","events_url":"https://api.github.com/repos/realm/realm-java/issues/3866/events","html_url":"https://github.com/realm/realm-java/issues/3866","id":193114284,"number":3866,"title":"Logout does not remove current user from UserStore","user":{"login":"joluet","id":6004861,"avatar_url":"https://avatars.githubusercontent.com/u/6004861?v=3","gravatar_id":"","url":"https://api.github.com/users/joluet","html_url":"https://github.com/joluet","followers_url":"https://api.github.com/users/joluet/followers","following_url":"https://api.github.com/users/joluet/following{/other_user}","gists_url":"https://api.github.com/users/joluet/gists{/gist_id}","starred_url":"https://api.github.com/users/joluet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joluet/subscriptions","organizations_url":"https://api.github.com/users/joluet/orgs","repos_url":"https://api.github.com/users/joluet/repos","events_url":"https://api.github.com/users/joluet/events{/privacy}","received_events_url":"https://api.github.com/users/joluet/received_events","type":"User","site_admin":false},"labels":[{"id":200279932,"url":"https://api.github.com/repos/realm/realm-java/labels/S:Waiting%20For%20User","name":"S:Waiting For User","color":"ededed","default":false},{"id":3545600,"url":"https://api.github.com/repos/realm/realm-java/labels/T:Help","name":"T:Help","color":"cc317c","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-12-02T13:18:37Z","updated_at":"2016-12-09T03:57:00Z","closed_at":null,"body":"Steps to reproduce:\r\n0. Make sure a user is logged in\r\n1. Call `SyncUser.currentUser().logout()` \r\n2. Kill the app manually\r\n3. Restart the app\r\n4. `SyncUser.currentUser()` still returns the user that should have been logged out\r\n\r\nThis looks like it could be the reason:\r\n`SyncUser.logout()` tries to remove the current user from the `UserStore` like this:\r\n```\r\nif (SyncUser.this.equals(SyncUser.currentUser())) {\r\n   SyncManager.getUserStore().remove(UserStore.CURRENT_USER_KEY);\r\n}\r\n```\r\nHowever, at that point `SyncUser.currentUser()` returns `null` because the user's token has already been removed in the line before and thus `isValid()` will return `false`. Therefore,  `remove(UserStore.CURRENT_USER_KEY)` is not executed."},"comment":{"url":"https://api.github.com/repos/realm/realm-java/issues/comments/265927677","html_url":"https://github.com/realm/realm-java/issues/3866#issuecomment-265927677","issue_url":"https://api.github.com/repos/realm/realm-java/issues/3866","id":265927677,"user":{"login":"joluet","id":6004861,"avatar_url":"https://avatars.githubusercontent.com/u/6004861?v=3","gravatar_id":"","url":"https://api.github.com/users/joluet","html_url":"https://github.com/joluet","followers_url":"https://api.github.com/users/joluet/followers","following_url":"https://api.github.com/users/joluet/following{/other_user}","gists_url":"https://api.github.com/users/joluet/gists{/gist_id}","starred_url":"https://api.github.com/users/joluet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joluet/subscriptions","organizations_url":"https://api.github.com/users/joluet/orgs","repos_url":"https://api.github.com/users/joluet/repos","events_url":"https://api.github.com/users/joluet/events{/privacy}","received_events_url":"https://api.github.com/users/joluet/received_events","type":"User","site_admin":false},"created_at":"2016-12-09T03:57:00Z","updated_at":"2016-12-09T03:57:00Z","body":"I don't think that issue is related to this one. As I explained above I think that the code in `SyncUser` does not work as intended. There is an if statement which prevents the current user from being removed from the `UserStore` because its condition is always false."}}
{"actor":{"display_login":"joluet"}}