Multiple permissions?

Hello,

is this allowed ? :

await window.safeMutableDataPermissionsSet.setAllow(permSet, ‘Insert’, ‘Update’ );

or should we do :

await window.safeMutableDataPermissionsSet.setAllow(permSet, [‘Insert’,‘Update’] );

or should we split this in 2 lines before applying ? I seem to have an issue with non owners being unable to update keys.

Specifically, after having setup a public mutable with what I think sets permissions for public : Insert and Update:

    // allowing the user to perform the Insert operation
    await window.safeMutableDataPermissionsSet.setAllow(permSet, PERMISSIONS.INSERT  ); // ???
    // setting the handle as null, anyone can perform the Insert and update operation
    await window.safeMutableData.setUserPermissions(this.topicsMutableData, null, permSet, 1);
    // allowing the user to perform the Update operation
    await window.safeMutableDataPermissionsSet.setAllow(permSet, PERMISSIONS.UPDATE ); // ????
    await window.safeMutableData.setUserPermissions(this.topicsMutableData, null, permSet, 2);

I get a nasty :

Error: Core error: Routing client error → Access denied

when a non owner tries to update one of the keys in the mutable.

The error message is a bit vague : are we denied access because the mutable was set badly ? Or is it because the app is not authorized correctly ?

1 Like

ah, well, in fact my issue came from setting the permissions on … the wrong mutable :face_with_hand_over_mouth:

lesson learned : don’t code after 2am

Still, is it possible to :

window.safeMutableDataPermissionsSet.setAllow(permSet, ‘Insert’, ‘Update’ );

or should we do it it 2 passes ?

2 Likes

You will be able to do such a thing in the next release of the API, e.g.:

window.safeMutableDataPermissions.insertPermissionsSet(permsHandle, signKeyHandle, ['Insert', 'Update']);
5 Likes

I am trying to do this with 0.4.3 :

const permSet = ['Insert', 'Update'];
const permsHandle = await window.safeMutableData.getPermissions(this.repliesMutableData);
await window.safeMutableDataPermissions.insertPermissionsSet(permsHandle, null, permSet);

EDIT : got it ! I was missing this :

await window.safeMutableData.setUserPermissions(this.repliesMutableData, null, permSet, 1);

and the ManagePermissions permission :slight_smile:

3 Likes

This topic was automatically closed after 60 days. New replies are no longer allowed.