Sha256: f09a609c9320abd441e4cb2b65a8445331e80628d80992f49a055d1386782ee5
Contents?: true
Size: 1.01 KB
Versions: 8
Compression:
Stored size: 1.01 KB
Contents
class ApplicationController < ActionController::Base before_action :set_current_request_details before_action :authenticate private def authenticate if session = Session.find_by_id(cookies.signed[:session_token]) Current.session = session else redirect_to sign_in_path end end def set_current_request_details Current.user_agent = request.user_agent Current.ip_address = request.ip end <%- if options.lockable? %> def require_lock(wait: 1.hour, attempts: 10) counter = Kredis.counter("require_lock:#{request.remote_ip}:#{controller_path}:#{action_name}", expires_in: wait) counter.increment if counter.value > attempts redirect_to root_path, alert: "You've exceeded the maximum number of attempts" end end <%- end -%> <%- if sudoable? %> def require_sudo unless Current.session.sudo? redirect_to new_sessions_sudo_path(proceed_to_url: request.original_url) end end <%- end -%> end
Version data entries
8 entries across 8 versions & 1 rubygems