Class Jpmobile::Rack::Auth
In: lib/jpmobile/rack/auth.rb
Parent: Object

req is Jpmobile::Rack::Request‘s subclass instance.

  require 'jpmobile/rack'
  use Jpmobile::Rack::Auth {|req|
    Your::Model::AuSubno.count(:subno => req.ident) != 0
  }

Methods

call   career   new  

Constants

FORBIDDEN = [403, {'Content-Type' => 'text/plain' }, 'Forbidden' ]

Public Class methods

[Source]

    # File lib/jpmobile/rack/auth.rb, line 23
23:       def initialize(app, hash=nil, &block)
24:         @app = app
25:         if hash
26:           @allow_ip         = hash[:allow_ip]
27:         end
28:         @cond = block
29:       end

Public Instance methods

[Source]

    # File lib/jpmobile/rack/auth.rb, line 34
34:       def call(env)
35:         request = Request.new(env)
36: 
37:         if request.mobile? and request.valid_ip?
38:           @app.call(env)
39:         else
40:           FORBIDDEN
41:         end
42:       end

[Source]

    # File lib/jpmobile/rack/auth.rb, line 31
31:       def career
32:       end

[Validate]