ishapi 0.1.8.126 → 0.1.8.131

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9916488f12cb2bd94d3b4c5ba8a34c9af25aed3c0b5482dc366e6ae4b03e378
4
- data.tar.gz: 380cb1a747514aef32d9b0551b18080c1758cc909028ff26069885b3729a6426
3
+ metadata.gz: f1802659d2e8c6ce8924c5e5645314e9c235d548f967b1c98041b80c22b5daf9
4
+ data.tar.gz: 2fb33453eb17bae2775ea7a2b3f8988bb044d853f5df16e3ce134c77a0d1725d
5
5
  SHA512:
6
- metadata.gz: '06697a5d9a73d070f5b6aea49fd0ec945fbd1e4fd68ee24cc70813f2b6b28ef6ccfbdbd143cf99c88cb372372bd5408e61cf16527070a1dd2a8b95fc9eacf60a'
7
- data.tar.gz: a7aaec299de3054be78848c7efe567506f51101794550cf5d0be7c2200b92c543f19c9fd5a39a71c3cda6a49bf0f21fb1d3fd413bd35747b87557a6328ff3138
6
+ metadata.gz: dc18bdfec85c2e6e3847f9936999f35a47df4e6a1bf1d791d7c1bd6cd55334ca7a0a4a10d12a1a9bf001cbcd6f0107fceb0c8ccd235717f86a254afae85c370d
7
+ data.tar.gz: bc6daf89813d973285525d8f8664408a1f97f7b07ab136c709f560f1de6c3627926120679bee7a42180cd9ce9707a1b34b2274ca9d27a9daa8c5702f204afe24
@@ -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
- render json: { long_term_token: @long_term_token }
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
- # byebug
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,16 @@
1
+
2
+ module Ishapi
3
+ module My
4
+ class VideosController < Ishapi::My::MyController
5
+
6
+ def index
7
+ authorize! :my_index, Video
8
+ puts! @current_user, 'current_user'
9
+
10
+ @videos = @current_user.profile.videos.unscoped.where( is_trash: false ).limit(20)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
16
+
@@ -10,6 +10,8 @@ module Ishapi
10
10
  end
11
11
 
12
12
  def my
13
+ puts! params, 'params 233'
14
+
13
15
  @profile = current_user.profile
14
16
  authorize! :show, @profile
15
17
  end
@@ -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
@@ -3,15 +3,18 @@
3
3
  # ishapi / application / _meta
4
4
  #
5
5
 
6
+ if !item.tags.blank?
7
+ json.partial! 'ishapi/tags/index', tags: item.tags
8
+ end
9
+ json.created_at item.created_at
10
+ json.updated_at item.updated_at
11
+ json.username item.user_profile.name if item.user_profile
6
12
  if item.city
7
13
  json.city do
8
14
  json.name item.city.name
15
+ json.slug item.city.cityname
9
16
  end
10
- json.cityname item.city.cityname
11
- end
12
- if defined?(item.tag) && !item.tag.blank?
13
- json.partial! 'ishapi/tags/index', tags: [ item.tag ]
14
- end
15
- if defined?(item.tags) && !item.tags.blank?
16
- json.partial! 'ishapi/tags/index', tags: item.tags
17
+ json.cityname item.city.cityname
17
18
  end
19
+ json.subhead item.subhead
20
+ json.description item.descr
@@ -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,8 +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
8
+ json.partial! 'ishapi/application/meta', item: @gallery
9
+ json.partial! 'ishapi/galleries/show', gallery: @gallery
10
10
  end
11
11
  end
12
12
 
@@ -0,0 +1,7 @@
1
+
2
+ json.videos(@videos) do |video|
3
+ json.name video.name
4
+ json.video_url video.video
5
+ json.thumb_url video.thumb
6
+ end
7
+
@@ -19,11 +19,6 @@ json.newsitems do
19
19
  json.n_photos item.gallery.photos.length
20
20
  json.slug item.gallery.galleryname
21
21
  json.subhead item.gallery.subhead
22
- json.tags [ { slug: 'adventure', name: 'Adventure' },
23
- { slug: 'bars-and-clubs', name: 'Bars & Clubs' },
24
- { slug: 'food', name: 'Food' },
25
- { slug: 'late-night', name: 'Late Night' } ]
26
-
27
22
  json.partial! 'ishapi/application/meta', :item => item.gallery
28
23
  if item.gallery.is_premium
29
24
  json.premium_tier item.gallery.premium_tier
@@ -49,7 +44,6 @@ json.newsitems do
49
44
  end
50
45
 
51
46
  json.partial! 'ishapi/application/meta', :item => item.report
52
- json.partial! 'ishapi/tags/index', tags: item.report.tags
53
47
 
54
48
  if item.report.is_premium
55
49
  json.premium_tier item.report.premium_tier
@@ -1,6 +1,7 @@
1
1
 
2
2
  #
3
3
  # ishapi / photos / _index
4
+ # @deprecated, ishapi / galleries / _show is preferred
4
5
  #
5
6
 
6
7
  json.photos do
@@ -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.126
4
+ version: 0.1.8.131
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-15 00:00:00.000000000 Z
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