debshots/app/controllers/application_controller.rb
2021-03-03 01:15:50 +01:00

36 lines
1 KiB
Ruby

class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
# Do not mention passwords in the log file
# filter_parameter_logging :password
before_action :moderate_packages, :get_ip
private
# If the current user is an administrator then show a second bar below
# the navigation bar that contains a paginator of packages that contain
# screenshots that require moderation.
def moderate_packages
if can? :approve, Screenshot and Package.need_moderation.any?
@moderate_packages = Package.need_moderation
end
end
# Define where the user is redirected to after a successful login.
def after_sign_in_path_for(resource)
my_profile_path
end
# Overwriting the sign_out redirect path method
def after_sign_out_path_for(resource_or_scope)
root_path
end
# Get the visitor's IP address to make it accessible to the Log model
def get_ip
@remote_ip = request.remote_ip
end
end