Module: Sinatra::GoogleAuth::Helpers

Defined in:
lib/sinatra/google-auth.rb

Instance Method Summary collapse

Instance Method Details

#authenticateObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/sinatra/google-auth.rb', line 25

def authenticate
  unless session["user"]
    session['google-auth-redirect'] = request.path
    if settings.absolute_redirect?
      redirect "/auth/google_apps"
    else
      redirect to "/auth/google_apps"
    end
  end
end

#handle_authentication_callbackObject



36
37
38
39
40
41
42
43
44
45
# File 'lib/sinatra/google-auth.rb', line 36

def handle_authentication_callback
  unless session["user"]
     = request.env["omniauth.auth"].info
    on_user() if respond_to? :on_user
    session["user"] = Array(.email).first.downcase
  end

  url = session['google-auth-redirect'] || to("/")
  redirect url
end