Module: Sinatra::GoogleAuth::Helpers
- Defined in:
- lib/sinatra/google-auth.rb
Instance Method Summary collapse
Instance Method Details
#authenticate ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sinatra/google-auth.rb', line 22 def authenticate unless session["user"] session['google-auth-redirect'] = request.path if settings.absolute_redirect? redirect "/auth/google" else redirect to "/auth/google" end end end |
#handle_authentication_callback ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/sinatra/google-auth.rb', line 33 def handle_authentication_callback unless session["user"] user_info = request.env["omniauth.auth"].info on_user(user_info) if respond_to? :on_user session["user"] = Array(user_info.email).first.downcase end url = session['google-auth-redirect'] || to("/") redirect url end |