Sha256: 3b7fc5c97dad8d34bc83611c8687ba07e98046ff9954a0b6b4486379a4cad7db
Contents?: true
Size: 1.6 KB
Versions: 1
Compression:
Stored size: 1.6 KB
Contents
module Lockup class LockupController < Lockup::ApplicationController skip_before_filter :check_for_lockup def unlock if params[:lockup_codeword].present? user_agent = request.env['HTTP_USER_AGENT'].downcase unless user_agent.match(/crawl|googlebot|slurp|spider|bingbot|tracker|click|parser|spider/) @codeword = params[:lockup_codeword].to_s.downcase @return_to = params[:return_to] if @codeword == ENV["LOCKUP_CODEWORD"].to_s.downcase || ((Rails::VERSION::MAJOR >= 4 && Rails::VERSION::MINOR >= 1) && @codeword == Rails.application.secrets.lockup_codeword.to_s.downcase) set_cookie run_redirect end else render nothing: true end elsif request.post? if params[:lockup].present? && params[:lockup].respond_to?(:'[]') @codeword = params[:lockup][:codeword].to_s.downcase @return_to = params[:lockup][:return_to] if @codeword == ENV["LOCKUP_CODEWORD"].to_s.downcase || ((Rails::VERSION::MAJOR >= 4 && Rails::VERSION::MINOR >= 1) && @codeword == Rails.application.secrets.lockup_codeword.to_s.downcase) set_cookie run_redirect else @wrong = true end else render nothing: true end end end private def set_cookie cookies[:lockup] = { value: @codeword.to_s.downcase, expires: (Time.now + 5.years) } end def run_redirect if @return_to.present? redirect_to "#{@return_to}" else redirect_to '/' end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lockup-1.3.1 | app/controllers/lockup/lockup_controller.rb |