Permissions not working

ros

#1

I called the following code

RLMSyncUser *currentUser = [RLMSyncUser currentUser];    
RLMSyncPermission *allUsersPermissionValue = [[RLMSyncPermission alloc] initWithRealmPath:orgPath identity:@"*" accessLevel:RLMSyncAccessLevelRead];
[currentUser applyPermission:allUsersPermissionValue callback:^(NSError *error) {
    if (error) {
        NSLog(@"error applying permission: %@", [error localizedDescription]);
        callback(FALSE, error);
    }
}];
NSLog(@"applying permissions for me");
RLMSyncPermission *myPermissionValue = [[RLMSyncPermission alloc] initWithRealmPath:orgPath identity:currentUser.identity accessLevel:RLMSyncAccessLevelAdmin];
[currentUser applyPermission:myPermissionValue callback:^(NSError *error) {
    if (error) {
        NSLog(@"error applying permission: %@", [error localizedDescription]);
        callback(FALSE, error);
    }
}];

and the permissions don’t seem to be applied. When I look in realm studio I see that the realm is “Owned by nobody” and the user permissions are “This realm has no permissions”. I don’t get any error when I call the above code and set the permissions.


#2

@nsnick I think I had similar issue like you, which is that the Admin user did not actually own the Realm that he is trying to share. Remember that private Realms have the tilde (~) that resolved to the user Id, the public Realm path does not have this tilde and there is no user with the id of “public” or “allUsers” so the Realm belonged to nobody as reported in the Realm Studio.

Once you grant the Manage permission to the admin user then it will be reflected in Realm Studio and your sharing will work. Hope that helps


#3

The problem was the fact that I was using ~ in the realm path instead of the full user id. After I switched it, I see the correct permissions in realm studio. I still can’t access the read only realm even when using asyncOpen. It gives permission denied even though in realm studio under user permissions it says “nobody R”.