can :create, Message if scopes.include?("send_messages")
if user.terms_agreed?
- can [:create, :update, :upload, :close, :subscribe, :unsubscribe], Changeset if scopes.include?("write_api")
- can :create, ChangesetComment if scopes.include?("write_api")
- can [:create, :update, :destroy], [Node, Way, Relation] if scopes.include?("write_api")
+ can [:create, :update, :upload, :close, :subscribe, :unsubscribe], Changeset if scopes.include?("write_map")
+ can :create, ChangesetComment if scopes.include?("write_changeset_comments")
+ can [:create, :update, :destroy], [Node, Way, Relation] if scopes.include?("write_map")
end
if user.moderator?
- can [:destroy, :restore], ChangesetComment if scopes.include?("write_api")
+ can [:destroy, :restore], ChangesetComment if scopes.include?("write_changeset_comments")
can :destroy, Note if scopes.include?("write_notes")
if doorkeeper_token&.accessible?
user = User.find(doorkeeper_token.resource_owner_id)
scopes = Set.new doorkeeper_token.scopes
+ if scopes.include?("write_api")
+ scopes.add("write_map")
+ scopes.add("write_changeset_comments")
+ scopes.delete("write_api")
+ end
ApiAbility.new(user, scopes)
else
ApiAbility.new(nil, Set.new)
url: Main Application URL (Required)
callback_url: Callback URL
support_url: Support URL
- allow_read_prefs: read their user preferences
+ allow_read_prefs: read their user preferences
allow_write_prefs: modify their user preferences
allow_write_diary: create diary entries and comments
- allow_write_api: modify the map
- allow_read_gpx: read their private GPS traces
- allow_write_gpx: upload GPS traces
+ allow_write_api: modify the map
+ allow_write_changeset_comments: comment on changesets
+ allow_read_gpx: read their private GPS traces
+ allow_write_gpx: upload GPS traces
allow_write_notes: modify notes
diary_comment:
body: "Body"
write_prefs: Modify user preferences
write_diary: Create diary entries and comments
write_api: Modify the map
+ write_changeset_comments: Comment on changesets
read_gpx: Read private GPS traces
write_gpx: Upload GPS traces
write_notes: Modify notes
module Oauth
SCOPES = %w[
read_prefs write_prefs write_diary
- write_api read_gpx write_gpx write_notes write_redactions
+ write_api write_changeset_comments read_gpx write_gpx write_notes write_redactions
consume_messages send_messages openid
].freeze
PRIVILEGED_SCOPES = %w[read_email skip_authorization].freeze
end
end
- test "as a normal user with write_api scope" do
+ test "as a normal user with write_changeset_comments scope" do
user = create(:user)
- scopes = Set.new %w[write_api]
+ scopes = Set.new %w[write_changeset_comments]
ability = ApiAbility.new user, scopes
[:destroy, :restore].each do |action|
end
end
- test "as a moderator with write_api scope" do
+ test "as a moderator with write_changeset_comments scope" do
user = create(:moderator_user)
- scopes = Set.new %w[write_api]
+ scopes = Set.new %w[write_changeset_comments]
ability = ApiAbility.new user, scopes
[:create, :destroy, :restore].each do |action|