ishapi 0.1.8.128 → 0.1.8.133
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/ishapi/application_controller.rb +40 -9
- data/app/controllers/ishapi/my/my_controller.rb +10 -1
- data/app/controllers/ishapi/my/videos_controller.rb +14 -0
- data/app/controllers/ishapi/user_profiles_controller.rb +2 -0
- data/app/models/ishapi/ability.rb +5 -2
- data/app/views/ishapi/galleries/_show.jbuilder +14 -1
- data/app/views/ishapi/galleries/show.jbuilder +1 -3
- data/app/views/ishapi/my/videos/index.jbuilder +9 -0
- data/app/views/ishapi/photos/_index.jbuilder +1 -0
- data/config/routes.rb +6 -4
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 214eb06a86cd16e99e941a3c22331117b6fde6f617d21149b26584718e81535b
|
4
|
+
data.tar.gz: 21b011a4ca8f9daf09753bb6ca3df95c5f8b536d321b586b9b193bcf65c03546
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bbfa9c73cb0e80eb74a7c52c2e40f120239445caabb62c153b65c21fe77258f088b289b18eab506b8a0a759ae913edae63c6561fbca2464b869ced7176a98a7
|
7
|
+
data.tar.gz: 3c62e845e6ec976248c8c94cd34b4bc87a370548319b8b2459560e0ed610c369ceac97e00dc5f76bb9c9805ba2d1c238b43897fd74c4a01e9722e6832694b8ee
|
@@ -7,7 +7,7 @@ module Ishapi
|
|
7
7
|
|
8
8
|
# before_action :check_profile, except: [ :test ]
|
9
9
|
before_action :set_current_ability
|
10
|
-
|
10
|
+
|
11
11
|
check_authorization
|
12
12
|
skip_before_action :verify_authenticity_token
|
13
13
|
|
@@ -26,9 +26,19 @@ module Ishapi
|
|
26
26
|
"client_id=#{FB[params['domain']][:app]}&client_secret=#{FB[params['domain']][:secret]}&" +
|
27
27
|
"fb_exchange_token=#{accessToken}"
|
28
28
|
j = JSON.parse response.body
|
29
|
+
puts! j, 'fb response'
|
29
30
|
@long_term_token = j['access_token']
|
30
31
|
|
31
|
-
|
32
|
+
# get user email
|
33
|
+
@graph = Koala::Facebook::API.new( accessToken )
|
34
|
+
@me = @graph.get_object( 'me', :fields => 'email' )
|
35
|
+
@current_user = User.where( :email => @me['email'] ).first
|
36
|
+
@profile = @current_user.profile
|
37
|
+
|
38
|
+
# send the jwt to client
|
39
|
+
@jwt_token = encode(user_id: @current_user.id)
|
40
|
+
|
41
|
+
render json: { long_term_token: @long_term_token, jwt_token: @jwt_token }
|
32
42
|
end
|
33
43
|
|
34
44
|
#
|
@@ -75,9 +85,9 @@ module Ishapi
|
|
75
85
|
# puts! result, 'googleauth result'
|
76
86
|
|
77
87
|
decoded_token = JWT.decode params[:idToken], nil, false
|
78
|
-
|
88
|
+
|
79
89
|
@current_user = User.find_by email: decoded_token[0]['email']
|
80
|
-
|
90
|
+
|
81
91
|
elsif 'facebook' == provider
|
82
92
|
# accessToken ||= params[:fb_long_access_token]
|
83
93
|
|
@@ -101,7 +111,7 @@ module Ishapi
|
|
101
111
|
@current_user = User.where( :email => @me['email'] ).first
|
102
112
|
@current_user ||= User.create! email: @me['email'], password: SecureRandom.urlsafe_base64
|
103
113
|
|
104
|
-
@current_profile = @current_user.profile
|
114
|
+
@current_profile = @current_user.profile
|
105
115
|
if !@current_profile
|
106
116
|
begin
|
107
117
|
g = Gallery.find '5e1495e2d697f768ad0779eb'
|
@@ -120,9 +130,15 @@ module Ishapi
|
|
120
130
|
|
121
131
|
puts! @current_user, 'current_user'
|
122
132
|
puts! @current_profile, 'current_profile'
|
123
|
-
|
133
|
+
|
134
|
+
elsif 'jwt' == provider
|
135
|
+
decoded = decode(params[:jwt_token])
|
136
|
+
puts! decoded, 'decoded'
|
137
|
+
@current_user = User.find decoded[:user_id]
|
138
|
+
|
124
139
|
else
|
125
140
|
puts! 'check_multiprofile(): no access token'
|
141
|
+
raise "ww1 - not implemented"
|
126
142
|
end
|
127
143
|
|
128
144
|
sign_in @current_user, scope: :user
|
@@ -132,13 +148,16 @@ module Ishapi
|
|
132
148
|
# this doesn't generate long-lived token, doesn't update user_profile
|
133
149
|
# this is only for facebook now
|
134
150
|
def check_profile
|
151
|
+
puts! params, 'params'
|
152
|
+
|
135
153
|
# return check_multiprofile 'google'
|
136
|
-
return check_multiprofile 'facebook'
|
154
|
+
# return check_multiprofile 'facebook'
|
155
|
+
return check_multiprofile 'jwt'
|
137
156
|
|
138
157
|
# puts! params, 'params'
|
139
158
|
# puts! current_user, 'current_user'
|
140
159
|
# puts! @current_user, '@current_user'
|
141
|
-
|
160
|
+
|
142
161
|
accessToken = request.headers[:accessToken]
|
143
162
|
accessToken ||= params[:fb_long_access_token]
|
144
163
|
accessToken ||= params[:accessToken]
|
@@ -201,7 +220,7 @@ module Ishapi
|
|
201
220
|
@current_order = @current_profile.current_order
|
202
221
|
# orders.where( :submitted_at => nil ).first || ::CoTailors::Order.new( :profile_id => @current_profile.id )
|
203
222
|
end
|
204
|
-
|
223
|
+
|
205
224
|
def get_long_token accessToken
|
206
225
|
url = "https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&" +
|
207
226
|
"client_id=#{FB[params['domain']][:app]}&client_secret=#{FB[params['domain']][:secret]}&fb_exchange_token=#{accessToken}"
|
@@ -221,5 +240,17 @@ module Ishapi
|
|
221
240
|
puts a.inspect
|
222
241
|
end
|
223
242
|
|
243
|
+
# jwt
|
244
|
+
def encode(payload, exp = 2.hours.from_now)
|
245
|
+
payload[:exp] = exp.to_i
|
246
|
+
JWT.encode(payload, Rails.application.secrets.secret_key_base.to_s)
|
247
|
+
end
|
248
|
+
|
249
|
+
# jwt
|
250
|
+
def decode(token)
|
251
|
+
decoded = JWT.decode(token, Rails.application.secrets.secret_key_base.to_s)[0]
|
252
|
+
HashWithIndifferentAccess.new decoded
|
253
|
+
end
|
254
|
+
|
224
255
|
end
|
225
256
|
end
|
@@ -3,10 +3,19 @@ module Ishapi
|
|
3
3
|
module My
|
4
4
|
class MyController < Ishapi::ApplicationController
|
5
5
|
|
6
|
-
before_action :set_profile
|
6
|
+
# before_action :set_profile # this is DoS on FB - disabled
|
7
|
+
before_action :do_login
|
7
8
|
|
8
9
|
private
|
9
10
|
|
11
|
+
def do_login
|
12
|
+
puts! params, 'params'
|
13
|
+
|
14
|
+
token = decode(params[:jwtToken])
|
15
|
+
puts! token, 'token'
|
16
|
+
@current_user = User.find(token["user_id"])
|
17
|
+
end
|
18
|
+
|
10
19
|
def set_profile
|
11
20
|
begin
|
12
21
|
@graph = Koala::Facebook::API.new( params[:accessToken] )
|
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
module Ishapi
|
3
|
+
module My
|
4
|
+
class VideosController < Ishapi::My::MyController
|
5
|
+
|
6
|
+
def index
|
7
|
+
authorize! :my_index, Video
|
8
|
+
@videos = @current_user.profile.videos.unscoped.where( is_trash: false ).order_by( created_at: :desc ).limit(20)
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
@@ -56,7 +56,7 @@ class Ishapi::Ability
|
|
56
56
|
can [ :my_index, :show ], Report do |report|
|
57
57
|
report.is_public
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
can [ :fb_sign_in, :long_term_token, :open_permission, :welcome_home ], Ishapi
|
61
61
|
|
62
62
|
can [ :index, :show ], Site
|
@@ -66,11 +66,14 @@ class Ishapi::Ability
|
|
66
66
|
tag.is_public
|
67
67
|
end
|
68
68
|
|
69
|
+
#
|
70
|
+
# V
|
71
|
+
#
|
69
72
|
can [ :index ], Venue
|
70
73
|
can [ :show ], Venue do |venue|
|
71
74
|
venue.is_public
|
72
75
|
end
|
73
|
-
can [ :index ], Video
|
76
|
+
can [ :index, :my_index ], Video
|
74
77
|
can [ :show ], Video do |video|
|
75
78
|
video.is_public
|
76
79
|
end
|
@@ -1,8 +1,21 @@
|
|
1
1
|
#
|
2
2
|
# ishapi / galleries / _show
|
3
3
|
#
|
4
|
-
|
5
4
|
json.id gallery.id.to_s
|
5
|
+
json.item_type 'gallery'
|
6
6
|
json.name gallery.name
|
7
7
|
json.galleryname gallery.galleryname
|
8
8
|
json.description gallery.description
|
9
|
+
json.username gallery.username || 'piousbox'
|
10
|
+
json.n_photos gallery.photos.length
|
11
|
+
json.slug gallery.galleryname
|
12
|
+
json.subhead gallery.subhead
|
13
|
+
json.partial! 'ishapi/application/meta', :item => gallery
|
14
|
+
if gallery.is_premium
|
15
|
+
json.premium_tier gallery.premium_tier
|
16
|
+
json.is_premium gallery.premium_tier > 0
|
17
|
+
json.is_purchased current_user.profile.has_premium_purchase( gallery )
|
18
|
+
json.partial! 'ishapi/photos/index', :photos => [ gallery.photos[0] ]
|
19
|
+
else
|
20
|
+
json.partial! 'ishapi/photos/index', :photos => gallery.photos
|
21
|
+
end
|
@@ -5,10 +5,8 @@
|
|
5
5
|
this_key = [ @gallery, params.permit! ]
|
6
6
|
json.cache! this_key do
|
7
7
|
json.gallery do
|
8
|
-
json.partial! 'ishapi/galleries/show', gallery: @gallery
|
9
|
-
json.partial! 'ishapi/photos/index', :photos => @gallery.photos
|
10
|
-
|
11
8
|
json.partial! 'ishapi/application/meta', item: @gallery
|
9
|
+
json.partial! 'ishapi/galleries/show', gallery: @gallery
|
12
10
|
end
|
13
11
|
end
|
14
12
|
|
data/config/routes.rb
CHANGED
@@ -7,7 +7,7 @@ Ishapi::Engine.routes.draw do
|
|
7
7
|
get 'cities', :to => 'cities#index'
|
8
8
|
get 'cities/view/:cityname', :to => 'cities#show'
|
9
9
|
get 'cities/features', :to => 'cities#features'
|
10
|
-
|
10
|
+
|
11
11
|
post 'co_tailors/orders', :to => 'orders#create'
|
12
12
|
post 'co_tailors/order_items', :to => 'order_items#create'
|
13
13
|
post 'co_tailors/measurements', :to => 'measurements#update'
|
@@ -16,7 +16,7 @@ Ishapi::Engine.routes.draw do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
post 'do_purchase', to: 'gameui#do_purchase'
|
19
|
-
|
19
|
+
|
20
20
|
get 'events/view/:eventname', :to => 'events#show'
|
21
21
|
|
22
22
|
get 'galleries', :to => 'galleries#index'
|
@@ -35,8 +35,10 @@ Ishapi::Engine.routes.draw do
|
|
35
35
|
namespace :my do
|
36
36
|
# post 'reports', :to => 'reports#index'
|
37
37
|
get 'reports', :to => 'reports#index'
|
38
|
+
get 'videos', to: 'videos#index'
|
39
|
+
post 'videos', to: 'videos#index'
|
38
40
|
end
|
39
|
-
|
41
|
+
|
40
42
|
post 'payments', :to => 'payments#create'
|
41
43
|
|
42
44
|
get 'profiles/view/:username', :to => 'user_profiles#show'
|
@@ -64,7 +66,7 @@ Ishapi::Engine.routes.draw do
|
|
64
66
|
|
65
67
|
get 'venues', :to => 'venues#index'
|
66
68
|
get 'venues/view/:venuename', :to => 'venues#show'
|
67
|
-
|
69
|
+
|
68
70
|
resources :videos
|
69
71
|
|
70
72
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ishapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.8.
|
4
|
+
version: 0.1.8.133
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -207,6 +207,7 @@ files:
|
|
207
207
|
- app/controllers/ishapi/measurements_controller.rb
|
208
208
|
- app/controllers/ishapi/my/my_controller.rb
|
209
209
|
- app/controllers/ishapi/my/reports_controller.rb
|
210
|
+
- app/controllers/ishapi/my/videos_controller.rb
|
210
211
|
- app/controllers/ishapi/newsitems_controller.rb
|
211
212
|
- app/controllers/ishapi/order_items_controller.rb
|
212
213
|
- app/controllers/ishapi/orders_controller.rb
|
@@ -248,6 +249,7 @@ files:
|
|
248
249
|
- app/views/ishapi/maps/index.jbuilder
|
249
250
|
- app/views/ishapi/maps/show.jbuilder
|
250
251
|
- app/views/ishapi/measurements/_show.jbuilder
|
252
|
+
- app/views/ishapi/my/videos/index.jbuilder
|
251
253
|
- app/views/ishapi/newsitems/_index.jbuilder
|
252
254
|
- app/views/ishapi/newsitems/index.jbuilder
|
253
255
|
- app/views/ishapi/orders/_item.jbuilder
|