Permalink
Browse files

small bug fixes, added github oauth 2 support

  • Loading branch information...
1 parent 69955c0 commit 904907491a42c7af0df9cbab1518d04d5c495984 @lancejpollard lancejpollard committed Jul 7, 2010
View
@@ -29,10 +29,8 @@
# Rails 3beta4 backport
if defined?(ActiveSupport::HashWithIndifferentAccess)
ActiveSupport::HashWithIndifferentAccess.class_eval do
- unless defined?(:symbolize_keys!)
- def symbolize_keys!
- symbolize_keys
- end
+ def symbolize_keys!
+ symbolize_keys
end
end
end
@@ -1,5 +1,7 @@
class GithubToken < OauthToken
+ version 2
+
key do |access_token|
user = JSON.parse(access_token.get("/api/v2/json/user/show"))
user["id"]
@@ -50,8 +50,10 @@ def restore_attributes
# it is called by the validation chain.
def complete_oauth_transaction
token = token_class.new(oauth_token_and_secret)
+ old_token = token_class.find_by_key_or_token(token.key, token.token)
+ token = old_token if old_token
- if has_token?(oauth_provider) || token_class.find_by_key_or_token(token.key, token.token)
+ if has_token?(oauth_provider)
self.errors.add(:tokens, "you have already created an account using your #{token_class.service_name} account, so it")
else
self.access_tokens << token

0 comments on commit 9049074

Please sign in to comment.