1 # frozen_string_literal: true
4 include CanCan::Ability
7 can :create, ChangesetComment if capability?(token, :allow_write_api)
8 can [:create, :comment, :close, :reopen], Note if capability?(token, :allow_write_notes)
9 can [:api_details], User if capability?(token, :allow_read_prefs)
10 can [:api_gpx_files], User if capability?(token, :allow_read_gpx)
11 can [:read, :read_one], UserPreference if capability?(token, :allow_read_prefs)
12 can [:update, :update_one, :delete_one], UserPreference if capability?(token, :allow_write_prefs)
14 if token&.user&.moderator?
15 can [:destroy, :restore], ChangesetComment if capability?(token, :allow_write_api)
16 can :destroy, Note if capability?(token, :allow_write_notes)
22 def capability?(token, cap)
23 token&.read_attribute(cap)