class Warden::JWTAuth::Middleware::TokenDispatcher

Dispatches a token (adds it to `Authorization` response header) if it has been added to the request `env` by [Hooks]

Constants

ENV_KEY

Debugging key added to `env`

Attributes

app[R]

Public Class Methods

new(app) click to toggle source
# File lib/warden/jwt_auth/middleware/token_dispatcher.rb, line 14
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/warden/jwt_auth/middleware/token_dispatcher.rb, line 18
def call(env)
  env[ENV_KEY] = true
  status, headers, response = app.call(env)
  headers = headers_with_token(env, headers)
  [status, headers, response]
end

Private Instance Methods

headers_with_token(env, headers) click to toggle source

:reek: UtilityFunction

# File lib/warden/jwt_auth/middleware/token_dispatcher.rb, line 28
def headers_with_token(env, headers)
  token = env[Hooks::PREPARED_TOKEN_ENV_KEY]
  token ? HeaderParser.to_headers(headers, token) : headers
end