osem-fcy/app/controllers/application_controller.rb

52 lines
1.1 KiB
Ruby
Raw Normal View History

2013-01-07 09:04:09 +01:00
class ApplicationController < ActionController::Base
include ApplicationHelper
protect_from_forgery
before_filter :get_conferences
def get_conferences
@conferences =Conference.all
end
2013-01-07 09:04:09 +01:00
def verify_user
:authenticate_user!
if (current_user.nil?)
redirect_to new_user_session_path
return false
2013-01-07 09:04:09 +01:00
end
@conference = Conference.find_all_by_short_title(params[:conference_id]).first
2013-01-15 14:08:22 +01:00
true
2013-01-07 09:04:09 +01:00
end
def organizer_or_admin?
has_role?(current_user, 'admin') || has_role?(current_user, 'organizer')
end
def verify_organizer
if !verify_user
return
end
2013-01-07 09:04:09 +01:00
## Todo simplify this
redirect_to root_path unless has_role?(current_user, 'admin') || has_role?(current_user, 'organizer')
2013-01-07 09:04:09 +01:00
end
def verify_admin
if !verify_user
return
end
2013-01-07 09:04:09 +01:00
redirect_to root_path unless has_role?(current_user, 'admin')
2013-01-07 09:04:09 +01:00
end
def current_ability
@current_ability ||= AdminAbility.new(current_user)
end
rescue_from CanCan::AccessDenied do |exception|
Rails.logger.debug("Access denied!")
redirect_to root_path, :alert => exception.message
2013-01-07 09:04:09 +01:00
end
end