Class: RubyAPI::Plugins::Auth

Inherits:
RubyAPI::Plugin show all
Defined in:
lib/rubyapi/plugins/auth.rb

Class Method Summary collapse

Methods inherited from RubyAPI::Plugin

inherited, option, options, plugin_name, register_cli, register_routes

Class Method Details

.on_load(app) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rubyapi/plugins/auth.rb', line 7

def self.on_load(app)
  app.before do |ctx|
    payload = ctx.get(:jwt_payload)
    unless payload
      status = options[:unauthorized_status]
      body = options[:unauthorized_body]
      ctx.response_status = status
      ctx.response_body = body
    end
  end
end