Class: ForgetPasswords::App
- Inherits:
-
Object
- Object
- ForgetPasswords::App
- Defined in:
- lib/forget-passwords.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(state, keys: {}, vars: {}, targets: {}, templates: {}, email: {}, debug: false) ⇒ App
constructor
A new instance of App.
Constructor Details
#initialize(state, keys: {}, vars: {}, targets: {}, templates: {}, email: {}, debug: false) ⇒ App
Returns a new instance of App.
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 |
# File 'lib/forget-passwords.rb', line 595 def initialize state, keys: {}, vars: {}, targets: {}, templates: {}, email: {}, debug: false @debug = debug # process config config = Config.({ state: state, keys: keys, vars: vars, targets: targets, templates: templates, email: email }).to_h # then assign members config.each { |key, value| instance_variable_set "@#{key.to_s}", value } # warn @email.inspect # create a dispatch table for content requests # XXX this will have to be expanded for multiple hosts @dispatch = @targets.reduce({}) do |a, pair| if proc = DISPATCH[pair.first] a[pair.last] ||= proc end a end.compact.to_h end |
Instance Method Details
#call(env) ⇒ Object
620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 |
# File 'lib/forget-passwords.rb', line 620 def call env # do surgery to request sceme if env['REQUEST_SCHEME'] env['HTTPS'] = 'on' if env['REQUEST_SCHEME'].downcase == 'https' end req = Rack::Request.new env resp = Rack::Response.new # keep this around for when we split this into app and middleware # unless env['FCGI_ROLE'] == 'AUTHORIZER' # resp.status = 500 # resp.body << "ForgetPasswords::App only works as a FastCGI authorizer!" # return resp.finish # end warn env.inspect if @debug begin resp = if env['FCGI_ROLE'] == 'AUTHORIZER' handle_auth req else handle_content req end rescue ForgetPasswords::ErrorResponse => e resp = e.response end return resp.finish end |