Sha256: e8b9f97113824f8fd1a5916dd731252a5b18af385f7d8dfa652038ce460910cb
Contents?: true
Size: 830 Bytes
Versions: 2
Compression:
Stored size: 830 Bytes
Contents
class ApplicationController < ActionController::Base before_action :set_current_request_details before_action :authenticate <%- if options.lockable? %> def require_lock(wait: 1.hour, attempts: 10) counter = Kredis.counter("require_lock:#{request.remote_ip}:#{params[:controller]}:#{params[:action]}", 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 -%> 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 end
Version data entries
2 entries across 2 versions & 1 rubygems