You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.6 KiB

class ApplicationController < ActionController::Base
13 years ago
protect_from_forgery
13 years ago
before_filter :check_honeypot
around_filter :set_timezone
12 years ago
helper_method :client_remote_ip
layout :scoped_layout
13 years ago
rescue_from ActiveScaffold::ActionNotAllowed do |exception|
flash.now[:error] = I18n.t("errors.action_not_allowed")
render_access_denied
13 years ago
end
13 years ago
protected
def set_timezone
old_time_zone = Time.zone
12 years ago
Time.zone = cookies[:time_zone] if cookies[:time_zone].present?
yield
ensure
Time.zone = old_time_zone
end
12 years ago
def scoped_layout
return false if request.xhr?
return 'admin' if devise_controller? && resource_name == :admin
user_signed_in? ? 'users' : 'public'
end
def render_access_denied
layout = request.xhr? ? false : 'errors'
render :template => 'errors/access_denied', :layout => layout
end
12 years ago
13 years ago
def client_remote_ip
@client_remote_ip ||= Settings.uses_proxy ? request.remote_ip : request.ip
13 years ago
end
13 years ago
def check_honeypot
render :nothing => true if params[Settings.honeypot].present?
end
def after_sign_out_path_for(resource_or_scope)
page_path('signed_out')
end
12 years ago
def current_ability
@current_ability ||= ::UserAbility.new(current_user)
end
class UserParameterSanitizer < Devise::ParameterSanitizer
def sign_up
default_params.permit(:full_name, :email, :password)
end
def account_update
default_params.permit(:full_name, :email, :password, :current_password)
end
end
def devise_parameter_sanitizer
super unless resource_class == User
UserParameterSanitizer.new(User, :user, params)
end
13 years ago
end