module Toker::TokenAuthentication
Public Instance Methods
current_user()
click to toggle source
# File lib/toker.rb, line 27 def current_user @user end
toke!(&unauthorized_handler)
click to toggle source
# File lib/toker.rb, line 9 def toke!(&unauthorized_handler) token = authenticate_with_http_token do |jwt, options| token, error = Token.decode(jwt) errors.merge!(error) if error token end @user = token.user if token unless @user if block_given? unauthorized_handler.call(errors) else render json: errors, status: :unauthorized end end end
Private Instance Methods
errors()
click to toggle source
# File lib/toker.rb, line 33 def errors @errors ||= { 'Unauthorized' => 'Token required' } end