Created
May 3, 2013 01:11
-
-
Save jonmarkgo/5506587 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if request.path_info == '/subcallback' #if we get a push from google, do a different lookup based on the userToken | |
@data = JSON.parse(request.body.read) | |
token_pair = TokenPair.get(@data['userToken']) | |
@phone_number = token_pair.phone_number | |
@client.authorization.update_token!(token_pair.to_hash) | |
else | |
if session[:token_id] #if the user is logged in | |
token_pair = TokenPair.get(session[:token_id]) | |
@client.authorization.update_token!(token_pair.to_hash) | |
@phone_number = token_pair.phone_number | |
else #if we are receiving an SMS | |
token_pair = TokenPair.first(:phone_number => params[:To]) | |
if !token_pair.nil? | |
@client.authorization.update_token!(token_pair.to_hash) | |
end | |
end | |
end | |
if @client.authorization.refresh_token && @client.authorization.expired? | |
@client.authorization.fetch_access_token! | |
end | |
#redirect the user to OAuth if we're logged out | |
unless @client.authorization.access_token || request.path_info =~ /^\/oauth2/ | |
redirect to("/oauth2authorize") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment