Sha256: 63e4e379bbf987b2d44c602e9d3db6a24619cc21fd7059d65baa64b584002ba8

Contents?: true

Size: 324 Bytes

Versions: 4

Compression:

Stored size: 324 Bytes

Contents

module Knock::Authenticable
  attr_reader :current_user

  def authenticate
    begin
      token = request.headers['Authorization'].split(' ').last
      payload, header = Knock::AuthToken.new(token: token).validate!
      @current_user = User.find(payload['user_id'])
    rescue
      head :unauthorized
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
knock-1.1.0 lib/knock/authenticable.rb
knock-1.1.0.rc1 lib/knock/authenticable.rb
knock-1.0.0 lib/knock/authenticable.rb
knock-1.0.0.rc1 lib/knock/authenticable.rb