1 # frozen_string_literal: true
4 include CanCan::Ability
7 if Settings.status != "database_offline"
8 user = User.find(token.resource_owner_id)
11 can [:create, :comment, :close, :reopen], Note if scope?(token, :write_notes)
12 can [:show, :data], Trace if scope?(token, :read_gpx)
13 can [:create, :update, :destroy], Trace if scope?(token, :write_gpx)
14 can [:details], User if scope?(token, :read_prefs)
15 can [:gpx_files], User if scope?(token, :read_gpx)
16 can [:index, :show], UserPreference if scope?(token, :read_prefs)
17 can [:update, :update_all, :destroy], UserPreference if scope?(token, :write_prefs)
18 can [:inbox, :outbox, :show, :update, :destroy], Message if scope?(token, :consume_messages)
19 can [:create], Message if scope?(token, :send_messages)
22 can [:create, :update, :upload, :close, :subscribe, :unsubscribe], Changeset if scope?(token, :write_api)
23 can :create, ChangesetComment if scope?(token, :write_api)
24 can [:create, :update, :delete], [Node, Way, Relation] if scope?(token, :write_api)
28 can [:destroy, :restore], ChangesetComment if scope?(token, :write_api)
29 can :destroy, Note if scope?(token, :write_notes)
30 can :redact, [OldNode, OldWay, OldRelation] if user&.terms_agreed? && scope?(token, :write_redactions)
38 def scope?(token, scope)
39 token&.includes_scope?(scope)