Sha256: c13f57d24d51d0272b4554c40793b8f9d5056acacd006d2604e04f4feb354162

Contents?: true

Size: 337 Bytes

Versions: 2

Compression:

Stored size: 337 Bytes

Contents

module Knock::Authenticable
  def current_user
    @current_user ||= begin
      token = params[:token] ||
        request.headers['Authorization'].match(/^Bearer (.*)$/)[1]

      Knock::AuthToken.new(token: token).current_user
    rescue
      nil
    end
  end

  def authenticate
    head :unauthorized unless current_user
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
knock-1.4.1 lib/knock/authenticable.rb
knock-1.4.0 lib/knock/authenticable.rb