twitter-auth 0.1.21 → 0.1.22
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.markdown +4 -0
- data/VERSION.yml +1 -1
- data/app/controllers/sessions_controller.rb +7 -3
- data/app/models/twitter_auth/generic_user.rb +12 -6
- data/lib/twitter_auth.rb +2 -1
- data/lib/twitter_auth/controller_extensions.rb +10 -3
- data/spec/controllers/controller_extensions_spec.rb +1 -1
- metadata +33 -34
data/CHANGELOG.markdown
CHANGED
data/VERSION.yml
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
class SessionsController < ApplicationController
|
2
|
+
unloadable
|
3
|
+
|
2
4
|
def new
|
3
5
|
if TwitterAuth.oauth?
|
4
|
-
|
6
|
+
oauth_callback = request.protocol + request.host_with_port + '/oauth_callback'
|
7
|
+
@request_token = TwitterAuth.consumer.get_request_token({:oauth_callback=>oauth_callback})
|
5
8
|
session[:request_token] = @request_token.token
|
6
9
|
session[:request_token_secret] = @request_token.secret
|
7
10
|
|
@@ -34,7 +37,8 @@ class SessionsController < ApplicationController
|
|
34
37
|
|
35
38
|
@request_token = OAuth::RequestToken.new(TwitterAuth.consumer, session[:request_token], session[:request_token_secret])
|
36
39
|
|
37
|
-
|
40
|
+
oauth_verifier = params["oauth_verifier"]
|
41
|
+
@access_token = @request_token.get_access_token(:oauth_verifier => oauth_verifier)
|
38
42
|
|
39
43
|
# The request token has been invalidated
|
40
44
|
# so we nullify it in the session.
|
@@ -48,7 +52,7 @@ class SessionsController < ApplicationController
|
|
48
52
|
cookies[:remember_token] = @user.remember_me
|
49
53
|
|
50
54
|
authentication_succeeded
|
51
|
-
rescue Net::HTTPServerException
|
55
|
+
rescue Net::HTTPServerException => e
|
52
56
|
case e.message
|
53
57
|
when '401 "Unauthorized"'
|
54
58
|
authentication_failed('This authentication request is no longer valid. Please try again.') and return
|
@@ -24,12 +24,14 @@ module TwitterAuth
|
|
24
24
|
:utc_offset
|
25
25
|
]
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
with_options :if => :utilize_default_validations do |v|
|
28
|
+
v.validates_presence_of :login, :twitter_id
|
29
|
+
v.validates_format_of :login, :with => /\A[a-z0-9_]+\z/i
|
30
|
+
v.validates_length_of :login, :in => 1..15
|
31
|
+
v.validates_uniqueness_of :login, :case_sensitive => false
|
32
|
+
v.validates_uniqueness_of :twitter_id, :message => "ID has already been taken."
|
33
|
+
v.validates_uniqueness_of :remember_token, :allow_blank => true
|
34
|
+
end
|
33
35
|
|
34
36
|
def self.table_name; 'users' end
|
35
37
|
|
@@ -70,6 +72,10 @@ module TwitterAuth
|
|
70
72
|
include TwitterAuth::BasicUser
|
71
73
|
end
|
72
74
|
|
75
|
+
def utilize_default_validations
|
76
|
+
true
|
77
|
+
end
|
78
|
+
|
73
79
|
def twitter
|
74
80
|
if TwitterAuth.oauth?
|
75
81
|
TwitterAuth::Dispatcher::Oauth.new(self)
|
data/lib/twitter_auth.rb
CHANGED
@@ -60,7 +60,8 @@ module TwitterAuth
|
|
60
60
|
[ :authorize_path,
|
61
61
|
:request_token_path,
|
62
62
|
:access_token_path,
|
63
|
-
:scheme
|
63
|
+
:scheme,
|
64
|
+
:signature_method ].each do |oauth_option|
|
64
65
|
options[oauth_option] = TwitterAuth.config[oauth_option.to_s] if TwitterAuth.config[oauth_option.to_s]
|
65
66
|
end
|
66
67
|
|
@@ -16,11 +16,18 @@ module TwitterAuth
|
|
16
16
|
|
17
17
|
def authentication_succeeded(message = 'You have logged in successfully.', destination = '/')
|
18
18
|
flash[:notice] = message
|
19
|
-
|
19
|
+
redirect_back_or_default destination
|
20
20
|
end
|
21
21
|
|
22
22
|
def current_user
|
23
|
-
@current_user ||=
|
23
|
+
@current_user ||=
|
24
|
+
if session[:user_id]
|
25
|
+
User.find_by_id(session[:user_id])
|
26
|
+
elsif cookies[:remember_token]
|
27
|
+
User.from_remember_token(cookies[:remember_token])
|
28
|
+
else
|
29
|
+
false
|
30
|
+
end
|
24
31
|
end
|
25
32
|
|
26
33
|
def current_user=(new_user)
|
@@ -55,8 +62,8 @@ module TwitterAuth
|
|
55
62
|
end
|
56
63
|
|
57
64
|
def logout_keeping_session!
|
58
|
-
@current_user = nil
|
59
65
|
session[:user_id] = nil
|
66
|
+
@current_user = nil
|
60
67
|
cookies.delete(:remember_token)
|
61
68
|
end
|
62
69
|
end
|
@@ -151,7 +151,7 @@ describe TwitterAuthTestController do
|
|
151
151
|
it 'should unset current_user' do
|
152
152
|
controller.send(:current_user).should == @user
|
153
153
|
get :logout_keeping_session_action
|
154
|
-
controller.send(:current_user).should
|
154
|
+
controller.send(:current_user).should be_false
|
155
155
|
end
|
156
156
|
|
157
157
|
it 'should unset the cookie' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twitter-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bleigh
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-06-19 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -42,66 +42,51 @@ extra_rdoc_files:
|
|
42
42
|
- README.markdown
|
43
43
|
files:
|
44
44
|
- CHANGELOG.markdown
|
45
|
-
- Rakefile
|
46
45
|
- README.markdown
|
46
|
+
- Rakefile
|
47
47
|
- VERSION.yml
|
48
|
-
-
|
49
|
-
-
|
48
|
+
- app/controllers/sessions_controller.rb
|
49
|
+
- app/models/twitter_auth/basic_user.rb
|
50
|
+
- app/models/twitter_auth/generic_user.rb
|
51
|
+
- app/models/twitter_auth/oauth_user.rb
|
52
|
+
- app/views/sessions/_login_form.html.erb
|
53
|
+
- app/views/sessions/new.html.erb
|
54
|
+
- config/routes.rb
|
55
|
+
- generators/twitter_auth/USAGE
|
50
56
|
- generators/twitter_auth/templates/migration.rb
|
51
57
|
- generators/twitter_auth/templates/twitter_auth.yml
|
52
58
|
- generators/twitter_auth/templates/user.rb
|
53
59
|
- generators/twitter_auth/twitter_auth_generator.rb
|
54
|
-
-
|
55
|
-
- lib/twitter_auth
|
60
|
+
- lib/twitter_auth.rb
|
56
61
|
- lib/twitter_auth/controller_extensions.rb
|
57
62
|
- lib/twitter_auth/cryptify.rb
|
58
|
-
- lib/twitter_auth/dispatcher
|
59
63
|
- lib/twitter_auth/dispatcher/basic.rb
|
60
64
|
- lib/twitter_auth/dispatcher/oauth.rb
|
61
65
|
- lib/twitter_auth/dispatcher/shared.rb
|
62
|
-
-
|
63
|
-
- spec/controllers
|
66
|
+
- rails/init.rb
|
64
67
|
- spec/controllers/controller_extensions_spec.rb
|
65
68
|
- spec/controllers/sessions_controller_spec.rb
|
66
|
-
- spec/fixtures
|
67
|
-
- spec/fixtures/config
|
68
69
|
- spec/fixtures/config/twitter_auth.yml
|
69
70
|
- spec/fixtures/factories.rb
|
70
71
|
- spec/fixtures/fakeweb.rb
|
71
72
|
- spec/fixtures/twitter.rb
|
72
|
-
- spec/models
|
73
|
-
- spec/models/twitter_auth
|
74
73
|
- spec/models/twitter_auth/basic_user_spec.rb
|
75
74
|
- spec/models/twitter_auth/generic_user_spec.rb
|
76
75
|
- spec/models/twitter_auth/oauth_user_spec.rb
|
77
76
|
- spec/schema.rb
|
78
77
|
- spec/spec.opts
|
79
78
|
- spec/spec_helper.rb
|
80
|
-
- spec/twitter_auth
|
81
79
|
- spec/twitter_auth/cryptify_spec.rb
|
82
|
-
- spec/twitter_auth/dispatcher
|
83
80
|
- spec/twitter_auth/dispatcher/basic_spec.rb
|
84
81
|
- spec/twitter_auth/dispatcher/oauth_spec.rb
|
85
82
|
- spec/twitter_auth/dispatcher/shared_spec.rb
|
86
83
|
- spec/twitter_auth_spec.rb
|
87
|
-
- config/routes.rb
|
88
|
-
- app/controllers
|
89
|
-
- app/controllers/sessions_controller.rb
|
90
|
-
- app/models
|
91
|
-
- app/models/twitter_auth
|
92
|
-
- app/models/twitter_auth/basic_user.rb
|
93
|
-
- app/models/twitter_auth/generic_user.rb
|
94
|
-
- app/models/twitter_auth/oauth_user.rb
|
95
|
-
- app/views
|
96
|
-
- app/views/sessions
|
97
|
-
- app/views/sessions/_login_form.html.erb
|
98
|
-
- app/views/sessions/new.html.erb
|
99
|
-
- rails/init.rb
|
100
84
|
has_rdoc: true
|
101
85
|
homepage: http://github.com/mbleigh/twitter-auth
|
86
|
+
licenses: []
|
87
|
+
|
102
88
|
post_install_message:
|
103
89
|
rdoc_options:
|
104
|
-
- --inline-source
|
105
90
|
- --charset=UTF-8
|
106
91
|
require_paths:
|
107
92
|
- lib
|
@@ -120,9 +105,23 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
105
|
requirements: []
|
121
106
|
|
122
107
|
rubyforge_project: twitter-auth
|
123
|
-
rubygems_version: 1.3.
|
108
|
+
rubygems_version: 1.3.3
|
124
109
|
signing_key:
|
125
|
-
specification_version:
|
110
|
+
specification_version: 3
|
126
111
|
summary: TwitterAuth is a Rails plugin gem that provides Single Sign-On capabilities for Rails applications via Twitter.
|
127
|
-
test_files:
|
128
|
-
|
112
|
+
test_files:
|
113
|
+
- spec/controllers/controller_extensions_spec.rb
|
114
|
+
- spec/controllers/sessions_controller_spec.rb
|
115
|
+
- spec/fixtures/factories.rb
|
116
|
+
- spec/fixtures/fakeweb.rb
|
117
|
+
- spec/fixtures/twitter.rb
|
118
|
+
- spec/models/twitter_auth/basic_user_spec.rb
|
119
|
+
- spec/models/twitter_auth/generic_user_spec.rb
|
120
|
+
- spec/models/twitter_auth/oauth_user_spec.rb
|
121
|
+
- spec/schema.rb
|
122
|
+
- spec/spec_helper.rb
|
123
|
+
- spec/twitter_auth/cryptify_spec.rb
|
124
|
+
- spec/twitter_auth/dispatcher/basic_spec.rb
|
125
|
+
- spec/twitter_auth/dispatcher/oauth_spec.rb
|
126
|
+
- spec/twitter_auth/dispatcher/shared_spec.rb
|
127
|
+
- spec/twitter_auth_spec.rb
|