Class: Sinatra::GoogleAuth::Middleware
- Inherits:
-
Object
- Object
- Sinatra::GoogleAuth::Middleware
- Defined in:
- lib/sinatra/google-auth.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
7 8 9 |
# File 'lib/sinatra/google-auth.rb', line 7 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/sinatra/google-auth.rb', line 11 def call(env) if env['rack.session']["user"] || env['REQUEST_PATH'] =~ /^\/auth\/google/ @app.call(env) else env['rack.session']['google-auth-redirect'] = env['REQUEST_PATH'] return [301, {'Content-Type' => 'text/html', 'Location' => '/auth/google'}, []] end end |