twitter-auth 0.1.13 → 0.1.14
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/app/controllers/sessions_controller.rb +1 -1
- data/app/models/twitter_auth/oauth_user.rb +5 -3
- data/lib/twitter_auth/dispatcher/basic.rb +1 -0
- data/lib/twitter_auth/dispatcher/oauth.rb +2 -1
- data/lib/twitter_auth/dispatcher/shared.rb +2 -0
- data/lib/twitter_auth.rb +4 -0
- data/spec/debug.log +1258 -0
- data/spec/twitter_auth_spec.rb +13 -1
- metadata +1 -1
data/VERSION.yml
CHANGED
@@ -48,7 +48,7 @@ class SessionsController < ApplicationController
|
|
48
48
|
cookies[:remember_token] = @user.remember_me
|
49
49
|
|
50
50
|
authentication_succeeded
|
51
|
-
rescue Net::HTTPServerException, Net::HTTPFatalError => e
|
51
|
+
rescue Net::HTTPServerException, Net::HTTPFatalError, TwitterAuth::Dispatcher::Error => e
|
52
52
|
case e.message
|
53
53
|
when '401 "Unauthorized"'
|
54
54
|
authentication_failed('This authentication request is no longer valid. Please try again.') and return
|
@@ -6,14 +6,16 @@ module TwitterAuth
|
|
6
6
|
end
|
7
7
|
|
8
8
|
base.extend TwitterAuth::OauthUser::ClassMethods
|
9
|
+
base.extend TwitterAuth::Dispatcher::Shared
|
9
10
|
end
|
10
11
|
|
11
12
|
module ClassMethods
|
12
13
|
def identify_or_create_from_access_token(token, secret=nil)
|
13
14
|
raise ArgumentError, 'Must authenticate with an OAuth::AccessToken or the string access token and secret.' unless (token && secret) || token.is_a?(OAuth::AccessToken)
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
|
16
|
+
response = token.get(TwitterAuth.path_prefix + '/account/verify_credentials.json')
|
17
|
+
user_info = handle_response(response)
|
18
|
+
|
17
19
|
if user = User.find_by_login(user_info['screen_name'])
|
18
20
|
user.assign_twitter_attributes(user_info)
|
19
21
|
user.access_token = token.token
|
@@ -15,6 +15,8 @@ module TwitterAuth
|
|
15
15
|
rescue JSON::ParserError
|
16
16
|
response.body
|
17
17
|
end
|
18
|
+
when Net::HTTPUnauthorized
|
19
|
+
raise TwitterAuth::Dispatcher::Error, 'The credentials provided did not authorize the user.'
|
18
20
|
else
|
19
21
|
message = begin
|
20
22
|
JSON.parse(response.body)['error']
|