Class: Sinatra::GoogleAuth::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra/google-auth.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



9
10
11
# File 'lib/sinatra/google-auth.rb', line 9

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/sinatra/google-auth.rb', line 13

def call(env)
  if env['rack.session']["user"] || env['REQUEST_PATH'] =~ /\/auth\/google_apps/
    @app.call(env)
  else
    env['rack.session']['google-auth-redirect'] = env['REQUEST_PATH']
    location = File.join(env['REQUEST_PATH'], '/auth/google_apps')
    return [301, {'Content-Type' => 'text/html', 'Location' => location}, []]
  end
end