work on authorization in controllers and refine ability.rb

This commit is contained in:
Stella Rouzi 2014-07-24 22:12:43 +03:00
parent 2d3a1ef37e
commit 0684dbad19
5 changed files with 23 additions and 39 deletions

View file

@ -34,11 +34,15 @@ class ApplicationController < ActionController::Base
@conferences =Conference.all
end
def authorize_conference
authorize! :update, @conference
end
def verify_user_admin
if self.class.to_s.split('::').first == 'Admin' && verify_user
unless (current_user.has_role? :organizer, :any) || (current_user.has_role? :cfp, :any) ||
(current_user.has_role? :info_desk, :any) ||
(current_user.has_role? :volunteers_coordinator, :any)
(current_user.has_role? :volunteers_coordinator, :any) || (current_user.is_admin)
raise CanCan::AccessDenied.new('You are not authorized to access this area!')
end
end