Sha256: 3145cb32b3d8a4ba74a06c17bb65e7be5db61666be29fc26149f21a19ac289dd

Contents?: true

Size: 581 Bytes

Versions: 2

Compression:

Stored size: 581 Bytes

Contents

class ApplicationController < ActionController::Base
  private

  def authenticate_user!
    if user_signed_in?
      visa_request.touch
    else
      render_plain_text 'Unauthorised', status: 401
    end
  end

  def current_user
    visa_request.tokenable
  end

  def render_plain_text(text, options = {})
    if Rails::VERSION::MAJOR == 4
      render options.merge(text: text)
    else
      render options.merge(plain: text)
    end
  end

  def visa_request
    @visa_request ||= Visa::Request.new request.env
  end

  def user_signed_in?
    visa_request.valid?
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
visa-0.1.0 spec/internal/app/controllers/application_controller.rb
visa-0.0.3 spec/internal/app/controllers/application_controller.rb