twitter-login 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/twitter/login.rb +17 -1
- metadata +4 -4
data/lib/twitter/login.rb
CHANGED
@@ -86,6 +86,14 @@ class Twitter::Login
|
|
86
86
|
|
87
87
|
url << path
|
88
88
|
end
|
89
|
+
|
90
|
+
def xhr?
|
91
|
+
!(env['HTTP_X_REQUESTED_WITH'] !~ /XMLHttpRequest/i)
|
92
|
+
end
|
93
|
+
|
94
|
+
def wants?(mime_type)
|
95
|
+
env['HTTP_ACCEPT'].to_s.include? mime_type
|
96
|
+
end
|
89
97
|
end
|
90
98
|
|
91
99
|
protected
|
@@ -96,7 +104,15 @@ class Twitter::Login
|
|
96
104
|
request.session[:twitter_request_token] = [request_token.token, request_token.secret]
|
97
105
|
|
98
106
|
# redirect to Twitter authorization page
|
99
|
-
|
107
|
+
if request.wants? 'application/json'
|
108
|
+
body = %({"authorize_url":"#{request_token.authorize_url}"})
|
109
|
+
["200", {'Content-type' => 'application/json'}, [body]]
|
110
|
+
elsif request.xhr? or request.wants? 'application/javascript'
|
111
|
+
body = "window.location.assign('#{request_token.authorize_url}')"
|
112
|
+
["200", {'Content-type' => 'application/javascript'}, [body]]
|
113
|
+
else
|
114
|
+
redirect request_token.authorize_url
|
115
|
+
end
|
100
116
|
end
|
101
117
|
|
102
118
|
def handle_twitter_authorization(request)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twitter-login
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 2
|
10
|
+
version: 0.4.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Mislav Marohni\xC4\x87"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-12-19 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|