twitter-login 0.2.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.markdown +10 -3
  2. data/lib/twitter/login.rb +9 -8
  3. metadata +18 -7
@@ -24,16 +24,23 @@ You have to require 'twitter/login' in your app. If you're using Bundler:
24
24
  gem 'twitter-login', :require_as => 'twitter/login'
25
25
 
26
26
  Now configure your app to use the middleware. This might be different across web
27
- frameworks.
27
+ frameworks. For Sinatra this would be:
28
28
 
29
29
  ## Sinatra
30
30
  enable :sessions
31
31
  use Twitter::Login, :consumer_key => 'KEY', :secret => 'SECRET'
32
32
  helpers Twitter::Login::Helpers
33
-
33
+
34
+ In Rails:
35
+
34
36
  ## Rails
37
+ # Gemfile (if using Bundler)
38
+ gem 'twitter-login', '~> 0.2.1', :require => 'twitter/login'
39
+
35
40
  # environment.rb:
36
- config.middleware.use Twitter::Login, :consumer_key => 'KEY', :secret => 'SECRET'
41
+ # (config.gem only in case you're not using Bundler)
42
+ config.gem 'twitter-login', :version => '~> 0.2.1', :lib => 'twitter/login'
43
+ config.middleware.use 'Twitter::Login', :consumer_key => 'KEY', :secret => 'SECRET'
37
44
 
38
45
  # application_controller.rb
39
46
  include Twitter::Login::Helpers
@@ -42,7 +42,7 @@ class Twitter::Login
42
42
  module Helpers
43
43
  def twitter_client
44
44
  oauth = twitter_oauth
45
- oauth.authorize_from_access(*session[:access_token])
45
+ oauth.authorize_from_access(*session[:twitter_access_token])
46
46
  Twitter::Base.new oauth
47
47
  end
48
48
 
@@ -57,7 +57,7 @@ class Twitter::Login
57
57
  end
58
58
 
59
59
  def twitter_logout
60
- [:access_token, :twitter_user].each do |key|
60
+ [:twitter_access_token, :twitter_user].each do |key|
61
61
  session[key] = nil # work around a Rails 2.3.5 bug
62
62
  session.delete key
63
63
  end
@@ -88,7 +88,7 @@ class Twitter::Login
88
88
  def redirect_to_twitter(request)
89
89
  # create a request token and store its parameter in session
90
90
  oauth.set_callback_url(request.url)
91
- request.session[:request_token] = [oauth.request_token.token, oauth.request_token.secret]
91
+ request.session[:twitter_request_token] = [oauth.request_token.token, oauth.request_token.secret]
92
92
  # redirect to Twitter authorization page
93
93
  redirect oauth.request_token.authorize_url
94
94
  end
@@ -118,8 +118,9 @@ class Twitter::Login
118
118
  end
119
119
 
120
120
  def handle_denied_access(request)
121
- request.session[:request_token] = nil # work around a Rails 2.3.5 bug
122
- request.session.delete(:request_token)
121
+ request.session[:twitter_request_token] = nil # work around a Rails 2.3.5 bug
122
+ request.session.delete(:twitter_request_token)
123
+ request.session[:twitter_error] = 'user_denied'
123
124
  redirect_to_return_path(request)
124
125
  end
125
126
 
@@ -127,11 +128,11 @@ class Twitter::Login
127
128
 
128
129
  # replace the request token in session with access token
129
130
  def authorize_from_request(request)
130
- rtoken, rsecret = request.session[:request_token]
131
+ rtoken, rsecret = request.session[:twitter_request_token]
131
132
  oauth.authorize_from_request(rtoken, rsecret, request[:oauth_verifier])
132
133
 
133
- request.session.delete(:request_token)
134
- request.session[:access_token] = [oauth.access_token.token, oauth.access_token.secret]
134
+ request.session.delete(:twitter_request_token)
135
+ request.session[:twitter_access_token] = [oauth.access_token.token, oauth.access_token.secret]
135
136
  end
136
137
 
137
138
  def redirect_to_return_path(request)
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter-login
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 17
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 2
8
- - 1
9
- version: 0.2.1
9
+ - 3
10
+ version: 0.2.3
10
11
  platform: ruby
11
12
  authors:
12
13
  - "Mislav Marohni\xC4\x87"
@@ -14,30 +15,34 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-03-10 00:00:00 -02:00
18
+ date: 2010-08-15 00:00:00 +02:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: twitter
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ~>
26
28
  - !ruby/object:Gem::Version
29
+ hash: 49
27
30
  segments:
28
31
  - 0
29
- - 8
30
- - 0
31
- version: 0.8.0
32
+ - 9
33
+ - 5
34
+ version: 0.9.5
32
35
  type: :runtime
33
36
  version_requirements: *id001
34
37
  - !ruby/object:Gem::Dependency
35
38
  name: rspec
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - ~>
40
44
  - !ruby/object:Gem::Version
45
+ hash: 13
41
46
  segments:
42
47
  - 1
43
48
  - 2
@@ -49,9 +54,11 @@ dependencies:
49
54
  name: fakeweb
50
55
  prerelease: false
51
56
  requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
52
58
  requirements:
53
59
  - - ~>
54
60
  - !ruby/object:Gem::Version
61
+ hash: 15
55
62
  segments:
56
63
  - 1
57
64
  - 2
@@ -81,23 +88,27 @@ rdoc_options: []
81
88
  require_paths:
82
89
  - lib
83
90
  required_ruby_version: !ruby/object:Gem::Requirement
91
+ none: false
84
92
  requirements:
85
93
  - - ">="
86
94
  - !ruby/object:Gem::Version
95
+ hash: 3
87
96
  segments:
88
97
  - 0
89
98
  version: "0"
90
99
  required_rubygems_version: !ruby/object:Gem::Requirement
100
+ none: false
91
101
  requirements:
92
102
  - - ">="
93
103
  - !ruby/object:Gem::Version
104
+ hash: 3
94
105
  segments:
95
106
  - 0
96
107
  version: "0"
97
108
  requirements: []
98
109
 
99
110
  rubyforge_project:
100
- rubygems_version: 1.3.6
111
+ rubygems_version: 1.3.7
101
112
  signing_key:
102
113
  specification_version: 3
103
114
  summary: Rack middleware to provide login functionality through Twitter