Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/plugin/permissions.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class Annotator.Plugin.Permissions extends Annotator.Plugin
# but our UI presents a checkbox, so we can only interpret "prevent others
# from viewing" as meaning "allow only me to view". This may want changing
# in the future.
annotation.permissions[type] = [@user]
annotation.permissions[type] = [@options.userId(@user)]

# Field callback: updates the annotation viewer to inlude the display name
# for the user obtained through Permissions#options.userString().
Expand Down
7 changes: 7 additions & 0 deletions test/spec/plugin/permissions_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,13 @@ describe 'Annotator.Plugin.Permissions', ->
checkbox.removeAttr('checked')
permissions.updateAnnotationPermissions('update', field, annotation)
assert.isFalse(permissions.authorize('update', annotation, null))

it 'should consult the userId option when updating permissions', ->
annotation = {permissions: {}}
permissions.options.userId = (user) -> user.id
permissions.setUser({id: 3, name: 'Alice'})
permissions.updateAnnotationPermissions('update', field, annotation);
assert.deepEqual(annotation.permissions, {'update': [3]})

describe 'updatePermissionsField', ->
field = null
Expand Down