Permalink
Browse files

set or update the secret when finding/creating token

Conflicts:

	lib/oauth/models/consumers/token.rb
  • Loading branch information...
1 parent 531ece1 commit 35c08bc9a66b8c6ab3dd1d54d39ae5d15a0f3cfe @pelle pelle committed Apr 5, 2011
Showing with 6 additions and 6 deletions.
  1. +1 −0 CHANGELOG
  2. +5 −6 lib/oauth/models/consumers/token.rb
View
@@ -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]
@@ -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

0 comments on commit 35c08bc

Please sign in to comment.