class GrapeTokenAuth::UnauthorizedMiddleware
Public Class Methods
call(env)
click to toggle source
# File lib/grape_token_auth/unauthorized_middleware.rb, line 4 def self.call(env) warden_opts = env.fetch('warden.options', {}) errors = warden_opts['errors'] || warden_opts[:errors] [401, { 'Content-Type' => 'application/json' }, prepare_errors(errors) ] end
prepare_errors(errors)
click to toggle source
# File lib/grape_token_auth/unauthorized_middleware.rb, line 14 def self.prepare_errors(errors) return [] unless errors return [errors.to_json] if errors.class == Hash return [{ 'errors' => errors }.to_json] if errors.class == String [] end