Module: Knock::Authenticable

Defined in:
lib/knock/authenticable.rb

Instance Method Summary collapse

Instance Method Details

#authenticateObject



11
12
13
# File 'lib/knock/authenticable.rb', line 11

def authenticate
  head :unauthorized unless current_user
end

#current_userObject



2
3
4
5
6
7
8
9
# File 'lib/knock/authenticable.rb', line 2

def current_user
  @current_user ||= begin
    token = params[:token] || request.headers['Authorization'].split.last
    Knock::AuthToken.new(token: token).current_user
  rescue
    nil
  end
end