Skip to content

Commit

Permalink
app: retrieves app info if not present when calling getAuthUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Bouvier committed Apr 9, 2013
1 parent 4bffb88 commit c6d3173
Showing 1 changed file with 36 additions and 27 deletions.
63 changes: 36 additions & 27 deletions lib/app.coffee
Expand Up @@ -81,43 +81,52 @@ class Application extends SubModule
cb 'no application id!'
return

if not @info
cb 'no application info!'
return
next = =>
# required parameters
if not @id or not @info.redirect_uris
cb 'missing required parameters when getting auth url: client_id, redirect_uris!'
return

# required parameters
if not @id or not @info.redirect_uri
cb 'missing required parameters when getting auth url: client_id, redirect_uri!'
scopes = @info.scopes || {}
scopes_str = Object.keys( scopes ).join ','

scopes = @info.scopes || {}
scopes_str = Object.keys( scopes ).join ','
profiles = @profile_info_types || []
profiles_str = profiles.map(@client.profile.expand).join ','

profiles = @profile_info_types || []
profiles_str = profiles.map(@client.profile.expand).join ','
posts = @post_types || []
posts_str = posts.map(@client.posts.expand).join ','

posts = @post_types || []
posts_str = posts.map(@client.posts.expand).join ','
utils.generateUniqueToken (state) =>
@state = state
authUrl = apiRootUrl + '/oauth/authorize?client_id=' + @id +
'&redirect_uri=' + @info.redirect_uris[0] +
'&response_type=code' +
'&state=' + state

utils.generateUniqueToken (state) =>
@state = state
authUrl = apiRootUrl + '/oauth/authorize?client_id=' + @id +
'&redirect_uri=' + @info.redirect_uris[0] +
'&response_type=code' +
'&state=' + state
if scopes_str.length > 0
authUrl += '&scope=' + scopes_str

if scopes_str.length > 0
authUrl += '&scope=' + scopes_str
if profiles_str.length > 0
authUrl += '&tent_profile_info_types=' + profiles_str

if profiles_str.length > 0
authUrl += '&tent_profile_info_types=' + profiles_str
if posts_str.length > 0
authUrl += '&tent_post_types=' + posts_str

if posts_str.length > 0
authUrl += '&tent_post_types=' + posts_str
if @notification_url
authUrl += '&tent_notification_url=' + @notification_url

if @notification_url
authUrl += '&tent_notification_url=' + @notification_url
cb null, authUrl, @info

cb null, authUrl, @info
if not @info
@get (err, appInfo) =>
if err
cb err
return

@info = appInfo
next()
else
next()
@

register: (appInfo, cb) =>
Expand Down

0 comments on commit c6d3173

Please sign in to comment.