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 [:create, :destroy], NoteSubscription if scope?(token, :write_notes)
13 can [:read, :data], Trace if scope?(token, :read_gpx)
14 can [:create, :update, :destroy], Trace if scope?(token, :write_gpx)
15 can [:details], User if scope?(token, :read_prefs)
16 can [:gpx_files], User if scope?(token, :read_gpx)
17 can :read, UserPreference if scope?(token, :read_prefs)
18 can [:update, :update_all, :destroy], UserPreference if scope?(token, :write_prefs)
19 can [:inbox, :outbox, :read, :update, :destroy], Message if scope?(token, :consume_messages)
20 can [:create], Message if scope?(token, :send_messages)
23 can [:create, :update, :upload, :close, :subscribe, :unsubscribe], Changeset if scope?(token, :write_api)
24 can :create, ChangesetComment if scope?(token, :write_api)
25 can [:create, :update, :delete], [Node, Way, Relation] if scope?(token, :write_api)
29 can [:destroy, :restore], ChangesetComment if scope?(token, :write_api)
30 can :destroy, Note if scope?(token, :write_notes)
31 can :redact, [OldNode, OldWay, OldRelation] if user&.terms_agreed? && scope?(token, :write_redactions)
39 def scope?(token, scope)
40 token&.includes_scope?(scope)