2011-10-18 19:31:59 +01:00
|
|
|
# coding: UTF-8
|
2011-03-09 13:13:36 +00:00
|
|
|
class ApplicationController < ActionController::Base
|
|
|
|
protect_from_forgery
|
2011-03-31 00:10:23 +01:00
|
|
|
layout :layout_by_resource
|
2011-10-21 15:57:29 +01:00
|
|
|
|
2011-03-31 00:10:23 +01:00
|
|
|
|
2011-10-14 21:45:58 +01:00
|
|
|
before_filter lambda { EventLog.current_controller = self }, :only => [:create, :destroy, :open_id] # :update
|
|
|
|
after_filter lambda { EventLog.current_controller = nil }
|
|
|
|
|
2011-10-27 13:49:21 +01:00
|
|
|
helper_method :get_owner
|
2011-03-31 00:10:23 +01:00
|
|
|
protected
|
2011-10-26 21:57:51 +01:00
|
|
|
def get_owner
|
|
|
|
params['user_id'] && User.find_by_id(params['user_id']) ||
|
|
|
|
params['group_id'] && Group.find_by_id(params['group_id']) || current_user
|
|
|
|
end
|
|
|
|
|
2011-03-31 00:10:23 +01:00
|
|
|
def layout_by_resource
|
|
|
|
if devise_controller?
|
|
|
|
"sessions"
|
|
|
|
else
|
|
|
|
"application"
|
|
|
|
end
|
|
|
|
end
|
2011-04-11 13:56:22 +01:00
|
|
|
|
2011-04-11 14:04:03 +01:00
|
|
|
def authenticate_build_service!
|
|
|
|
if request.remote_ip != APP_CONFIG['build_service_ip']
|
|
|
|
render :nothing => true, :status => 403
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def authenticate_product_builder!
|
|
|
|
if request.remote_ip != APP_CONFIG['product_builder_ip']
|
2011-04-11 13:56:22 +01:00
|
|
|
render :nothing => true, :status => 403
|
|
|
|
end
|
|
|
|
end
|
2011-03-09 13:13:36 +00:00
|
|
|
end
|