Use CanCanCan for traces controller

This commit is contained in:
Andy Allan 2019-01-09 11:40:54 +01:00
parent fac3f0ef24
commit 414c4b2c36
3 changed files with 8 additions and 3 deletions

View file

@ -11,6 +11,7 @@ class Ability
:search_geonames, :search_osm_nominatim_reverse, :search_geonames_reverse], :geocoder
can [:index, :create, :comment, :feed, :show, :search, :mine], Note
can [:index, :show], Redaction
can [:index, :show, :data, :georss, :picture, :icon], Trace
can [:terms, :api_users, :login, :logout, :new, :create, :save, :confirm, :confirm_resend, :confirm_email, :lost_password, :reset_password, :show, :api_read, :auth_success, :auth_failure], User
can [:index, :show, :blocks_on, :blocks_by], UserBlock
@ -19,6 +20,7 @@ class Ability
can [:create, :edit, :comment, :subscribe, :unsubscribe], DiaryEntry
can [:close, :reopen], Note
can [:new, :create], Report
can [:mine, :new, :create, :edit, :update, :delete, :api_create, :api_read, :api_update, :api_delete, :api_data], Trace
can [:account, :go_public, :make_friend, :remove_friend, :api_details, :api_gpx_files], User
can [:read, :read_one, :update, :update_one, :delete_one], UserPreference

View file

@ -5,6 +5,8 @@ class Capability
def initialize(token)
can [:create, :comment, :close, :reopen], Note if capability?(token, :allow_write_notes)
can [:api_read, :api_data], Trace if capability?(token, :allow_read_gpx)
can [:api_create, :api_update, :api_delete], Trace if capability?(token, :allow_write_gpx)
can [:api_details], User if capability?(token, :allow_read_prefs)
can [:api_gpx_files], User if capability?(token, :allow_read_gpx)
can [:read, :read_one], UserPreference if capability?(token, :allow_read_prefs)