Skip to content

Commit

Permalink
set or update the secret when finding/creating token
Browse files Browse the repository at this point in the history
Conflicts:

	lib/oauth/models/consumers/token.rb
  • Loading branch information
pelle committed Apr 5, 2011
1 parent 531ece1 commit 35c08bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
@@ -1,4 +1,5 @@
0.4.0-pre5
- fix issues with new consumer tokens [afeld]
- More forgiving about oob callback values[chrisrhoden]
- Update Twitter consumer to use latest Twitter Gem [afeld]
- Fixes various mongoid issues [3en]
Expand Down
11 changes: 5 additions & 6 deletions lib/oauth/models/consumers/token.rb
Expand Up @@ -40,15 +40,14 @@ def find_or_create_from_request_token(user,token,secret,oauth_verifier)
def find_or_create_from_access_token(user,access_token)
secret = access_token.respond_to?(:secret) ? access_token.secret : nil
if user
token = self.find_or_create_by_user_id_and_token_and_secret(user.id, access_token.token, secret)
token = self.find_or_initialize_by_user_id_and_token(user.id, access_token.token)
else
token = self.find_or_create_by_token_and_secret(access_token.token, secret)
token = self.find_or_initialize_by_token(access_token.token)
end

if token.new_record?
token.secret = secret
token.save
end
# set or update the secret
token.secret = secret
token.save! if token.new_record? or token.changed?

token
end
Expand Down

0 comments on commit 35c08bc

Please sign in to comment.