sharkapps 0.1.15 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -2
- data/Gemfile.lock +10 -0
- data/VERSION +1 -1
- data/config/routes.rb +1 -0
- data/lib/sharkapps.rb +52 -3
- data/sharkapps.gemspec +5 -2
- metadata +29 -14
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -28,16 +28,24 @@ GEM
|
|
28
28
|
activemodel (= 3.0.9)
|
29
29
|
activesupport (= 3.0.9)
|
30
30
|
activesupport (3.0.9)
|
31
|
+
addressable (2.2.7)
|
31
32
|
arel (2.0.10)
|
32
33
|
builder (2.1.2)
|
33
34
|
erubis (2.6.6)
|
34
35
|
abstract (>= 1.0.0)
|
36
|
+
faraday (0.7.6)
|
37
|
+
addressable (~> 2.2)
|
38
|
+
multipart-post (~> 1.1)
|
39
|
+
rack (~> 1.1)
|
35
40
|
git (1.2.5)
|
36
41
|
i18n (0.5.0)
|
37
42
|
jeweler (1.5.2)
|
38
43
|
bundler (~> 1.0.0)
|
39
44
|
git (>= 1.2.5)
|
40
45
|
rake
|
46
|
+
koala (1.4.0)
|
47
|
+
faraday (~> 0.7.0)
|
48
|
+
multi_json (~> 1.0)
|
41
49
|
mail (2.2.19)
|
42
50
|
activesupport (>= 2.3.6)
|
43
51
|
i18n (>= 0.4.0)
|
@@ -45,6 +53,7 @@ GEM
|
|
45
53
|
treetop (~> 1.4.8)
|
46
54
|
mime-types (1.16)
|
47
55
|
multi_json (1.3.2)
|
56
|
+
multipart-post (1.1.5)
|
48
57
|
polyglot (0.3.2)
|
49
58
|
rabl (0.6.9)
|
50
59
|
activesupport (>= 2.3.14)
|
@@ -85,6 +94,7 @@ PLATFORMS
|
|
85
94
|
DEPENDENCIES
|
86
95
|
bundler (~> 1.0.0)
|
87
96
|
jeweler (~> 1.5.2)
|
97
|
+
koala
|
88
98
|
rabl
|
89
99
|
rails (>= 3.0.9)
|
90
100
|
rcov
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.16
|
data/config/routes.rb
CHANGED
@@ -3,6 +3,7 @@ Rails.application.routes.draw do
|
|
3
3
|
match 'locale_selector' => 'appforma#locale_selector', :as => :locale_selector
|
4
4
|
match 'not_subscribed' => 'appforma#not_subscribed', :as => :not_subscribed
|
5
5
|
match 'not_authorized' => 'appforma#not_authorized', :as => :not_authorized
|
6
|
+
match 'auth_check' => 'appforma#auth_check', :as => :site_auth_check
|
6
7
|
|
7
8
|
#API routes
|
8
9
|
scope "/api/v1" do
|
data/lib/sharkapps.rb
CHANGED
@@ -106,7 +106,35 @@ module SharkApps
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def check_admin
|
109
|
-
|
109
|
+
#check that we have a Facebook user. if not, redirect.
|
110
|
+
@oauth = Koala::Facebook::OAuth.new(Facebooker2.app_id, Facebooker2.secret)
|
111
|
+
|
112
|
+
#returning from the oauth server
|
113
|
+
if params[:code] and session[:access_token].nil?
|
114
|
+
@access_token = @oauth.get_access_token(params[:code], :redirect_uri => session[:redirect_uri])
|
115
|
+
session[:redirect_uri] = nil
|
116
|
+
session[:access_token] = @access_token
|
117
|
+
end
|
118
|
+
|
119
|
+
#no access token stored - do a redirect
|
120
|
+
unless session[:access_token]
|
121
|
+
session[:redirect_uri] = request.url
|
122
|
+
redirect_to @oauth.url_for_oauth_code(:permissions => "publish_stream, manage_pages, email", :redirect_uri => request.url) and return
|
123
|
+
end
|
124
|
+
|
125
|
+
#validate that the access token that we have is good. if not, request a new one.
|
126
|
+
begin
|
127
|
+
fb = current_fb_user
|
128
|
+
rescue Exception
|
129
|
+
session[:redirect_uri] = request.url
|
130
|
+
session[:access_token] = nil
|
131
|
+
redirect_to @oauth.url_for_oauth_code(:permissions => "publish_stream, manage_pages, email", :redirect_uri => request.url) and return
|
132
|
+
end
|
133
|
+
|
134
|
+
#we have an access token, we can do the is_admin check now
|
135
|
+
unless session[:access_token].nil?
|
136
|
+
redirect_to not_authorized_url(:id => @account.acc_hash) unless is_admin
|
137
|
+
end
|
110
138
|
end
|
111
139
|
|
112
140
|
def is_admin
|
@@ -124,12 +152,33 @@ module SharkApps
|
|
124
152
|
need_check = (session[sym].nil? or session[sym] == false)
|
125
153
|
puts "need check: = #{need_check}"
|
126
154
|
if need_check #need_check
|
127
|
-
return false if
|
128
|
-
session[sym] = AppformaAccount.check_admin_authorized(@account,
|
155
|
+
return false if current_fb_user.nil?
|
156
|
+
session[sym] = AppformaAccount.check_admin_authorized(@account, current_fb_user['id'])
|
129
157
|
end
|
130
158
|
return session[sym]
|
131
159
|
end
|
132
160
|
end
|
161
|
+
|
162
|
+
def facebook_session_from_cookies
|
163
|
+
puts "request cookies = #{request.cookies}"
|
164
|
+
oauth = Koala::Facebook::OAuth.new(Facebooker2.app_id, Facebooker2.secret)
|
165
|
+
facebook_session = oauth.get_user_info_from_cookies(request.cookies)
|
166
|
+
facebook_session
|
167
|
+
end
|
168
|
+
|
169
|
+
def facebook_user_from_cookies
|
170
|
+
facebook_session = facebook_session_from_cookies
|
171
|
+
@facebook_user = Koala::Facebook::API.new(facebook_session["access_token"]).get_object("me") if facebook_session
|
172
|
+
@access_token = facebook_session["access_token"] if facebook_session
|
173
|
+
@facebook_user
|
174
|
+
end
|
175
|
+
|
176
|
+
def current_fb_user
|
177
|
+
return @current_fb_user if @current_fb_user
|
178
|
+
@current_fb_user = Koala::Facebook::API.new(session[:access_token]).get_object("me") if session[:access_token]
|
179
|
+
@current_fb_user
|
180
|
+
end
|
181
|
+
|
133
182
|
|
134
183
|
end
|
135
184
|
|
data/sharkapps.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sharkapps}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.16"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Eyal Kedem"]
|
12
|
-
s.date = %q{2012-
|
12
|
+
s.date = %q{2012-06-03}
|
13
13
|
s.description = %q{integration utilities with the shark apps framework}
|
14
14
|
s.email = %q{ekedem@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -66,6 +66,7 @@ Gem::Specification.new do |s|
|
|
66
66
|
|
67
67
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
68
68
|
s.add_runtime_dependency(%q<rabl>, [">= 0"])
|
69
|
+
s.add_runtime_dependency(%q<koala>, [">= 0"])
|
69
70
|
s.add_development_dependency(%q<rails>, [">= 3.0.9"])
|
70
71
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
71
72
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
@@ -73,6 +74,7 @@ Gem::Specification.new do |s|
|
|
73
74
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
74
75
|
else
|
75
76
|
s.add_dependency(%q<rabl>, [">= 0"])
|
77
|
+
s.add_dependency(%q<koala>, [">= 0"])
|
76
78
|
s.add_dependency(%q<rails>, [">= 3.0.9"])
|
77
79
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
78
80
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
@@ -81,6 +83,7 @@ Gem::Specification.new do |s|
|
|
81
83
|
end
|
82
84
|
else
|
83
85
|
s.add_dependency(%q<rabl>, [">= 0"])
|
86
|
+
s.add_dependency(%q<koala>, [">= 0"])
|
84
87
|
s.add_dependency(%q<rails>, [">= 3.0.9"])
|
85
88
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
86
89
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sharkapps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
9
|
+
- 16
|
10
10
|
segments_generated: true
|
11
|
-
version: 0.1.
|
11
|
+
version: 0.1.16
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Eyal Kedem
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-
|
19
|
+
date: 2012-06-03 00:00:00 +03:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -35,8 +35,23 @@ dependencies:
|
|
35
35
|
prerelease: false
|
36
36
|
type: :runtime
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
38
|
+
name: koala
|
39
39
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
segments_generated: true
|
48
|
+
version: "0"
|
49
|
+
requirement: *id002
|
50
|
+
prerelease: false
|
51
|
+
type: :runtime
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: rails
|
54
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
40
55
|
none: false
|
41
56
|
requirements:
|
42
57
|
- - ">="
|
@@ -48,12 +63,12 @@ dependencies:
|
|
48
63
|
- 9
|
49
64
|
segments_generated: true
|
50
65
|
version: 3.0.9
|
51
|
-
requirement: *
|
66
|
+
requirement: *id003
|
52
67
|
prerelease: false
|
53
68
|
type: :development
|
54
69
|
- !ruby/object:Gem::Dependency
|
55
70
|
name: shoulda
|
56
|
-
version_requirements: &
|
71
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
57
72
|
none: false
|
58
73
|
requirements:
|
59
74
|
- - ">="
|
@@ -63,12 +78,12 @@ dependencies:
|
|
63
78
|
- 0
|
64
79
|
segments_generated: true
|
65
80
|
version: "0"
|
66
|
-
requirement: *
|
81
|
+
requirement: *id004
|
67
82
|
prerelease: false
|
68
83
|
type: :development
|
69
84
|
- !ruby/object:Gem::Dependency
|
70
85
|
name: bundler
|
71
|
-
version_requirements: &
|
86
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
72
87
|
none: false
|
73
88
|
requirements:
|
74
89
|
- - ~>
|
@@ -80,12 +95,12 @@ dependencies:
|
|
80
95
|
- 0
|
81
96
|
segments_generated: true
|
82
97
|
version: 1.0.0
|
83
|
-
requirement: *
|
98
|
+
requirement: *id005
|
84
99
|
prerelease: false
|
85
100
|
type: :development
|
86
101
|
- !ruby/object:Gem::Dependency
|
87
102
|
name: jeweler
|
88
|
-
version_requirements: &
|
103
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
89
104
|
none: false
|
90
105
|
requirements:
|
91
106
|
- - ~>
|
@@ -97,12 +112,12 @@ dependencies:
|
|
97
112
|
- 2
|
98
113
|
segments_generated: true
|
99
114
|
version: 1.5.2
|
100
|
-
requirement: *
|
115
|
+
requirement: *id006
|
101
116
|
prerelease: false
|
102
117
|
type: :development
|
103
118
|
- !ruby/object:Gem::Dependency
|
104
119
|
name: rcov
|
105
|
-
version_requirements: &
|
120
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
106
121
|
none: false
|
107
122
|
requirements:
|
108
123
|
- - ">="
|
@@ -112,7 +127,7 @@ dependencies:
|
|
112
127
|
- 0
|
113
128
|
segments_generated: true
|
114
129
|
version: "0"
|
115
|
-
requirement: *
|
130
|
+
requirement: *id007
|
116
131
|
prerelease: false
|
117
132
|
type: :development
|
118
133
|
description: integration utilities with the shark apps framework
|