Class: Carpool::Passenger
- Inherits:
-
Object
- Object
- Carpool::Passenger
- Includes:
- Mixins::Core
- Defined in:
- lib/carpool/passenger.rb
Class Attribute Summary collapse
-
.driver_uri ⇒ Object
Returns the value of attribute driver_uri.
-
.secret ⇒ Object
Returns the value of attribute secret.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) {|Carpool::Passenger| ... } ⇒ Passenger
constructor
A new instance of Passenger.
Methods included from Mixins::Core
Constructor Details
Class Attribute Details
.driver_uri ⇒ Object
Returns the value of attribute driver_uri.
10 11 12 |
# File 'lib/carpool/passenger.rb', line 10 def driver_uri @driver_uri end |
.secret ⇒ Object
Returns the value of attribute secret.
11 12 13 |
# File 'lib/carpool/passenger.rb', line 11 def secret @secret end |
Instance Method Details
#call(env) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/carpool/passenger.rb', line 22 def call(env) @env = env @params = CGI.parse(env['QUERY_STRING']) [:scope] = "passenger" # If this isn't an authorize request from the driver, just ignore it. return @app.call(env) unless valid_request? && valid_referrer? # If we can't find our payload, then we need to abort. return [500, {}, 'Invalid seatbelt.'] if @params['seatbelt'].nil? or @params['seatbelt'].blank? # Set a custom HTTP header for our payload and send the request to the user's /sso/authorize handler. env['X-CARPOOL-PAYLOAD'] = @params['seatbelt'] return @app.call(env) end |