Add authorization for toggle_favorite and rename route

This commit is contained in:
Stella Rouzi 2018-09-20 00:45:50 +03:00 committed by Henne Vogelsang
parent 2485923319
commit 91629d9b92
5 changed files with 11 additions and 5 deletions

View file

@ -6,7 +6,8 @@ class ProposalsController < ApplicationController
load_resource :program, through: :conference, singleton: true
load_and_authorize_resource :event, parent: false, through: :program
# We authorize manually in these actions
skip_authorize_resource :event, only: [:confirm, :restart, :toogle_favorite, :withdraw]
skip_authorize_resource :event, only: [:confirm, :restart, :withdraw]
def index
@event = @program.events.new
@ -85,7 +86,8 @@ class ProposalsController < ApplicationController
render action: 'edit'
end
end
def toogle_favorite
def toggle_favorite
user = User.find(params[:favourite_user_id])
users = @event.favourite_users
if users.include? user