Disable registration/event submission without sign in with ichain

This commit is contained in:
Henne Vogelsang 2015-04-23 11:50:22 +02:00
parent 4ed8a72967
commit 132fe6f98c
3 changed files with 18 additions and 7 deletions

View file

@ -44,7 +44,9 @@ class ApplicationController < ActionController::Base
rescue_from CanCan::AccessDenied do |exception| rescue_from CanCan::AccessDenied do |exception|
Rails.logger.debug "Access denied on #{exception.action} #{exception.subject.inspect}" Rails.logger.debug "Access denied on #{exception.action} #{exception.subject.inspect}"
redirect_to root_path, alert: exception.message message = exception.message
message << ' Maybe you need to sign in?' if !current_user
redirect_to root_path, alert: message
end end
rescue_from IChainRecordNotFound do rescue_from IChainRecordNotFound do

View file

@ -49,12 +49,13 @@ class Ability
# can view Commercials of confirmed Events # can view Commercials of confirmed Events
can :show, Commercial, commercialable_type: 'Event', commercialable_id: Event.where(state: 'confirmed').pluck(:id) can :show, Commercial, commercialable_type: 'Event', commercialable_id: Event.where(state: 'confirmed').pluck(:id)
can :show, User can :show, User
can [:show, :create], Registration do |registration| unless CONFIG['authentication']['ichain']['enabled']
registration.new_record? can [:show, :create], Registration do |registration|
end registration.new_record?
end
can [:show, :create], Event do |event| can [:show, :create], Event do |event|
event.new_record? event.new_record?
end
end end
end end

View file

@ -85,4 +85,12 @@ Osem::Application.configure do
} }
) )
config.after_initialize do
Devise.setup do |devise_config|
# Enable ichain test mode
devise_config.ichain_test_mode = true
end
end
end end