Want to check to see if there is currently a user logged in but there are already several users logged in
Our documentation asserts that checking for a logged in user would be done by checking if SynUser.current != nil in the case of multiple active profiles this causes an exception.
SyncUser.current returns non- Nil for any condition where the are logged in users/profiles
Crash:
2017-05-22 14:35:33.557 RealmBingo[33458:4855586] *** Terminating app due to uncaught exception 'RLMException', reason: '+currentUser cannot be called if more that one valid, logged-in user exists.'
N/a
Realm framework version: RealmSwift 2.7.0
Realm Object Server version: 1.4.1
Xcode version: 8.2.3
iOS/OSX version: 10.12.5
Dependency manager + version: ?
This is documented behavior:
The currentUser method will retrieve the current user, the last user who logged in and whose credentials have not expired. The method returns nil if no current user exists. An exception will be thrown if more than one logged-in user exists.
I feel this is correct as it might be misleading/undefined if there are more than one logged in users. You should use allUsers if your application supports such a scenario.
Hi, you can check your active users session this way (Swift code):
for user in SyncUser.all {
debugPrint("user: \(user.key) - \(user.value)")
}
You will se something like this:
"user: a9c2de623e408422a3073b3276d54517 - <RLMSyncUser: 0x174247b90>"
"user: 0a12e0b10e217f228d4f313679f68c4d - <RLMSyncUser: 0x174246300>"
To call SyncUser.current without error you have to quit all other users session. For example:
for user in SyncUser.all {
debugPrint("user: \(user.key) - \(user.value)")
user.value.logOut()
}
Most helpful comment
Hi, you can check your active users session this way (Swift code):
You will se something like this:
To call
SyncUser.currentwithout error you have to quit all other users session. For example: