1 # frozen_string_literal: true
4 include CanCan::Ability
7 if Settings.status != "database_offline"
8 can [:create, :comment, :close, :reopen], Note if capability?(token, :allow_write_notes)
9 can [:show, :data], Trace if capability?(token, :allow_read_gpx)
10 can [:create, :update, :destroy], Trace if capability?(token, :allow_write_gpx)
11 can [:details], User if capability?(token, :allow_read_prefs)
12 can [:gpx_files], User if capability?(token, :allow_read_gpx)
13 can [:index, :show], UserPreference if capability?(token, :allow_read_prefs)
14 can [:update, :update_all, :destroy], UserPreference if capability?(token, :allow_write_prefs)
16 if token&.user&.terms_agreed?
17 can [:create, :update, :upload, :close, :subscribe, :unsubscribe], Changeset if capability?(token, :allow_write_api)
18 can :create, ChangesetComment if capability?(token, :allow_write_api)
19 can [:create, :update, :delete], Node if capability?(token, :allow_write_api)
20 can [:create, :update, :delete], Way if capability?(token, :allow_write_api)
21 can [:create, :update, :delete], Relation if capability?(token, :allow_write_api)
24 if token&.user&.moderator?
25 can [:destroy, :restore], ChangesetComment if capability?(token, :allow_write_api)
26 can :destroy, Note if capability?(token, :allow_write_notes)
27 if token&.user&.terms_agreed?
28 can :redact, OldNode if capability?(token, :allow_write_api)
29 can :redact, OldWay if capability?(token, :allow_write_api)
30 can :redact, OldRelation if capability?(token, :allow_write_api)
38 def capability?(token, cap)
39 token&.read_attribute(cap)