1 # frozen_string_literal: true
4 include CanCan::Ability
7 can :create, ChangesetComment if capability?(token, :allow_write_api)
8 can [:read, :read_one], UserPreference if capability?(token, :allow_read_prefs)
9 can [:update, :update_one, :delete_one], UserPreference if capability?(token, :allow_write_prefs)
11 if token&.user&.moderator?
12 can [:destroy, :restore], ChangesetComment if capability?(token, :allow_write_api)
18 def capability?(token, cap)
19 token&.read_attribute(cap)