Sha256: 771dc16c0530ffee93694b6ce9990ec608d8623ed4be851948a25d53c255a3a3

Contents?: true

Size: 611 Bytes

Versions: 2

Compression:

Stored size: 611 Bytes

Contents

class ApplicationController < ActionController::Base
  before_action :set_current_request_details
  before_action :authenticate

  def require_sudo
    if Current.session.sudo_at < 30.minutes.ago
      redirect_to new_sessions_sudo_path(proceed_to_url: request.url)
    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

Version Path
authentication-zero-2.10.0 lib/generators/authentication/templates/controllers/html/application_controller.rb.tt
authentication-zero-2.9.3 lib/generators/authentication/templates/controllers/html/application_controller.rb.tt