ishapi 0.1.8.133 → 0.1.8.134
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/ishapi/application_controller.rb +37 -13
- data/app/controllers/ishapi/gameui_controller.rb +2 -2
- data/app/controllers/ishapi/my/my_controller.rb +10 -1
- data/app/controllers/ishapi/payments_controller.rb +74 -2
- data/app/controllers/ishapi/sites_controller.rb +3 -2
- data/app/controllers/ishapi/user_profiles_controller.rb +0 -7
- data/app/models/ishapi/ability.rb +11 -4
- data/app/views/ishapi/{user_profiles/my.jbuilder → my/my/account.jbuilder} +2 -0
- data/app/views/ishapi/newsitems/_index.jbuilder +4 -4
- data/app/views/ishapi/sites/show.jbuilder +2 -2
- data/config/routes.rb +12 -11
- metadata +6 -7
- data/app/controllers/ishapi/api_controller.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9055c8aee254cef203fa0ba8a7c82fd98d7c4b66870342d2286201ef7613dbd
|
4
|
+
data.tar.gz: eee54217f1e118989c390a1e7b73c49284f441504f661f1d4b189da385436720
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38e5d8e9948fd4c50e4df5045e1a3e8c2e8789b45b6f8697cd7f8b6d966cf48f59869ea73399e596e75457eeca9ea351d0f488e0e8bb9ee6029f0001829e3ca9
|
7
|
+
data.tar.gz: 0e633543d607411b971a437d9ad7f28f603a54754ff667ded394ac046fa9b2b64e4bdb2c0b1a1ae2ff1a8f13f6dc53ee0c284cd8148f7dbe0ba6acae1170bdfb
|
@@ -22,23 +22,32 @@ module Ishapi
|
|
22
22
|
|
23
23
|
params['domain'] = 'tgm.piousbox.com'
|
24
24
|
|
25
|
-
response = HTTParty.get "https://graph.facebook.com/v5.0/oauth/access_token?grant_type=fb_exchange_token&" +
|
25
|
+
response = ::HTTParty.get "https://graph.facebook.com/v5.0/oauth/access_token?grant_type=fb_exchange_token&" +
|
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
|
-
|
30
|
-
@long_term_token = j['access_token']
|
31
|
-
|
32
|
-
# get user email
|
29
|
+
@long_term_token = j['access_token']
|
33
30
|
@graph = Koala::Facebook::API.new( accessToken )
|
34
31
|
@me = @graph.get_object( 'me', :fields => 'email' )
|
35
32
|
@current_user = User.where( :email => @me['email'] ).first
|
36
|
-
|
33
|
+
|
34
|
+
puts! @current_user, '#long_term_token @current_user'
|
37
35
|
|
38
36
|
# send the jwt to client
|
39
|
-
@jwt_token = encode(user_id: @current_user.id)
|
37
|
+
@jwt_token = encode(user_id: @current_user.id.to_s)
|
38
|
+
|
39
|
+
render json: {
|
40
|
+
email: @current_user.email,
|
41
|
+
jwt_token: @jwt_token,
|
42
|
+
long_term_token: @long_term_token,
|
43
|
+
n_unlocks: @current_user.profile.n_unlocks,
|
44
|
+
}
|
45
|
+
end
|
40
46
|
|
41
|
-
|
47
|
+
def home
|
48
|
+
authorize! :welcome_home, Ishapi
|
49
|
+
render :json => { :status => :ok, :message => 'Ishapi::ApiController.home',
|
50
|
+
:n_reports => Report.count, :n_cities => City.count }
|
42
51
|
end
|
43
52
|
|
44
53
|
#
|
@@ -73,7 +82,6 @@ module Ishapi
|
|
73
82
|
## Does not crap out if accessToken is missing
|
74
83
|
def soft_check_long_term_token
|
75
84
|
check_long_term_token soft=true
|
76
|
-
# puts! @profile, 'soft_check_long_term_token() profile'
|
77
85
|
end
|
78
86
|
|
79
87
|
def check_multiprofile provider = 'google'
|
@@ -132,21 +140,37 @@ module Ishapi
|
|
132
140
|
puts! @current_profile, 'current_profile'
|
133
141
|
|
134
142
|
elsif 'jwt' == provider
|
135
|
-
|
136
|
-
|
137
|
-
|
143
|
+
begin
|
144
|
+
decoded = decode(params[:jwt_token])
|
145
|
+
rescue JWT::ExpiredSignature
|
146
|
+
# @TODO: refactor [ref-5]
|
147
|
+
@current_user = User.new profile: Profile.new
|
148
|
+
sign_in @current_user, scope: :user
|
149
|
+
set_current_ability
|
150
|
+
return
|
151
|
+
end
|
152
|
+
@current_user = User.find decoded['user_id']
|
138
153
|
|
139
154
|
else
|
140
155
|
puts! 'check_multiprofile(): no access token'
|
141
156
|
raise "ww1 - not implemented"
|
142
157
|
end
|
143
158
|
|
159
|
+
# @TODO: refactor [ref-5]
|
144
160
|
sign_in @current_user, scope: :user
|
145
161
|
set_current_ability
|
146
162
|
end
|
147
163
|
|
164
|
+
# same as check_profile but doesn't error out when jwt_token is missing
|
165
|
+
def check_profile_optionally
|
166
|
+
if !params[:jwt_token]
|
167
|
+
@current_user = User.new profile: Profile.new
|
168
|
+
else
|
169
|
+
check_profile
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
148
173
|
# this doesn't generate long-lived token, doesn't update user_profile
|
149
|
-
# this is only for facebook now
|
150
174
|
def check_profile
|
151
175
|
puts! params, 'params'
|
152
176
|
|
@@ -21,7 +21,7 @@ module Ishapi
|
|
21
21
|
:amount => params[:amount],
|
22
22
|
:currency => 'usd',
|
23
23
|
:source => params[:stripeToken],
|
24
|
-
:destination => {
|
24
|
+
:destination => {
|
25
25
|
:account => acct,
|
26
26
|
}
|
27
27
|
)
|
@@ -46,7 +46,7 @@ module Ishapi
|
|
46
46
|
def do_purchase
|
47
47
|
authorize! :do_purchase, ::Gameui
|
48
48
|
item = params[:className].constantize.find_by_slug( params[:slug] )
|
49
|
-
|
49
|
+
|
50
50
|
raise 'no such item' if !item
|
51
51
|
raise 'too little funds' if @profile.n_stars < item.premium_tier
|
52
52
|
|
@@ -4,7 +4,16 @@ module Ishapi
|
|
4
4
|
class MyController < Ishapi::ApplicationController
|
5
5
|
|
6
6
|
# before_action :set_profile # this is DoS on FB - disabled
|
7
|
-
before_action :do_login
|
7
|
+
# before_action :do_login
|
8
|
+
before_action :check_profile
|
9
|
+
|
10
|
+
def account
|
11
|
+
puts! params, 'my account'
|
12
|
+
|
13
|
+
@profile = current_user.profile
|
14
|
+
authorize! :show, @profile
|
15
|
+
end
|
16
|
+
|
8
17
|
|
9
18
|
private
|
10
19
|
|
@@ -2,6 +2,12 @@ require_dependency "ishapi/application_controller"
|
|
2
2
|
module Ishapi
|
3
3
|
class PaymentsController < ApplicationController
|
4
4
|
|
5
|
+
before_action :check_profile, only: %i| create2 unlock |
|
6
|
+
|
7
|
+
##
|
8
|
+
## this is for invoices on wasya.co, isn't it?
|
9
|
+
## 20200712
|
10
|
+
##
|
5
11
|
def create
|
6
12
|
authorize! :open_permission, ::Ishapi
|
7
13
|
begin
|
@@ -18,11 +24,10 @@ module Ishapi
|
|
18
24
|
:amount => amount_cents,
|
19
25
|
:currency => 'usd',
|
20
26
|
:source => params[:token][:id],
|
21
|
-
:destination => {
|
27
|
+
:destination => {
|
22
28
|
:account => acct,
|
23
29
|
}
|
24
30
|
)
|
25
|
-
# puts! charge, 'charge'
|
26
31
|
|
27
32
|
payment.charge = JSON.parse( charge.to_json )
|
28
33
|
if payment.save
|
@@ -36,6 +41,73 @@ module Ishapi
|
|
36
41
|
end
|
37
42
|
end
|
38
43
|
|
44
|
+
## This is for guyd _vp_ 20200721
|
45
|
+
def create2
|
46
|
+
authorize! :create, ::Ish::Payment
|
47
|
+
|
48
|
+
begin
|
49
|
+
amount_cents = 503 # @TODO: change
|
50
|
+
|
51
|
+
::Stripe.api_key = STRIPE_SK
|
52
|
+
intent = Stripe::PaymentIntent.create({
|
53
|
+
amount: amount_cents,
|
54
|
+
currency: 'usd',
|
55
|
+
metadata: { integration_check: "accept_a_payment" },
|
56
|
+
})
|
57
|
+
|
58
|
+
payment = Ish::Payment.create!(
|
59
|
+
client_secret: intent.client_secret,
|
60
|
+
email: @current_user.email,
|
61
|
+
payment_intent_id: intent.id,
|
62
|
+
profile_id: @current_user.profile.id )
|
63
|
+
|
64
|
+
render json: { client_secret: intent.client_secret }
|
65
|
+
rescue Mongoid::Errors::DocumentNotFound => e
|
66
|
+
puts! e, 'e'
|
67
|
+
render :status => 404, :json => e
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
## webhook
|
72
|
+
def stripe_confirm
|
73
|
+
authorize! :open_permission, ::Ishapi
|
74
|
+
payload = request.body.read
|
75
|
+
event = nil
|
76
|
+
begin
|
77
|
+
event = Stripe::Event.construct_from(JSON.parse(payload, symbolize_names: true))
|
78
|
+
rescue StandardError => e
|
79
|
+
puts! e, 'e'
|
80
|
+
render status: 400, json: { status: :not_ok }
|
81
|
+
return
|
82
|
+
end
|
83
|
+
|
84
|
+
payment_intent = event.data.object
|
85
|
+
|
86
|
+
payment = Ish::Payment.where( payment_intent_id: payment_intent.id ).first
|
87
|
+
if payment && payment_intent['status'] == 'succeeded'
|
88
|
+
payment.update_attributes( status: :confirmed )
|
89
|
+
payment.profile.update_attributes!( n_unlocks: payment.profile.n_unlocks + 5 )
|
90
|
+
end
|
91
|
+
|
92
|
+
render status: 200, json: { status: :ok }
|
93
|
+
end
|
94
|
+
|
95
|
+
def unlock
|
96
|
+
authorize! :unlock, ::Ish::Payment
|
97
|
+
item = Object::const_get(params['kind']).find params['id']
|
98
|
+
|
99
|
+
existing = Purchase.where( user_profile: @current_user.profile, item: item ).first
|
100
|
+
if existing
|
101
|
+
render status: 200, json: { status: :ok, message: 'already purchased' }
|
102
|
+
return
|
103
|
+
end
|
104
|
+
|
105
|
+
@current_user.profile.update_attributes n_unlocks: @current_user.profile.n_unlocks - 1 # @TODO: the number is variable
|
106
|
+
purchase = ::Gameui::PremiumPurchase.create!( item: item, user_profile: @current_user.profile, )
|
107
|
+
|
108
|
+
render status: 200, json: { status: :ok }
|
109
|
+
end
|
110
|
+
|
39
111
|
end
|
40
112
|
end
|
41
113
|
|
@@ -3,6 +3,8 @@ require_dependency "ishapi/application_controller"
|
|
3
3
|
module Ishapi
|
4
4
|
class SitesController < ApplicationController
|
5
5
|
|
6
|
+
before_action :check_profile_optionally, only: %i| show |
|
7
|
+
|
6
8
|
def index
|
7
9
|
authorize! :index, ::Site
|
8
10
|
@sites = ::Site.all
|
@@ -14,10 +16,9 @@ module Ishapi
|
|
14
16
|
else
|
15
17
|
domain = params[:domain]
|
16
18
|
end
|
17
|
-
@site = ::Site.find_by
|
19
|
+
@site = ::Site.find_by(domain: domain, lang: :en)
|
18
20
|
authorize! :show, @site
|
19
21
|
|
20
|
-
|
21
22
|
if @site.is_private
|
22
23
|
if !params[:accessToken]
|
23
24
|
render :json => { :status => :unauthorized}, :status => :unauthorized
|
@@ -13,15 +13,17 @@ class Ishapi::Ability
|
|
13
13
|
can :manage, :all
|
14
14
|
end
|
15
15
|
|
16
|
+
can [ :update ], ::CoTailors::Address do |address|
|
17
|
+
puts [ user.inspect, address.inspect ], '+++ user in cancancan'
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
16
21
|
can [ :show ], Gallery do |gallery|
|
17
22
|
gallery.user_profile == user.profile
|
18
23
|
end
|
19
24
|
can [ :do_purchase ], ::Gameui
|
20
25
|
|
21
|
-
can [ :
|
22
|
-
puts [ user.inspect, address.inspect ], '+++ user in cancancan'
|
23
|
-
true
|
24
|
-
end
|
26
|
+
can [ :create, :unlock ], ::Ish::Payment
|
25
27
|
|
26
28
|
can [ :buy_stars ], ::IshModels::UserProfile
|
27
29
|
|
@@ -42,6 +44,11 @@ class Ishapi::Ability
|
|
42
44
|
|
43
45
|
can [ :index, :show ], Event
|
44
46
|
|
47
|
+
#
|
48
|
+
# Ish::P
|
49
|
+
#
|
50
|
+
|
51
|
+
|
45
52
|
#
|
46
53
|
# G
|
47
54
|
#
|
@@ -10,7 +10,7 @@ json.newsitems do
|
|
10
10
|
json.name item.name
|
11
11
|
json.created_at item.created_at
|
12
12
|
json.updated_at item.updated_at
|
13
|
-
|
13
|
+
|
14
14
|
if item.gallery
|
15
15
|
json.item_type 'gallery'
|
16
16
|
json.name item.gallery.name
|
@@ -39,7 +39,7 @@ json.newsitems do
|
|
39
39
|
json.username item.report.user_profile.name if item.report.user_profile
|
40
40
|
|
41
41
|
if item.report.photo
|
42
|
-
json.photo_s169_url item.report.photo.photo.url( :s169 )
|
42
|
+
json.photo_s169_url item.report.photo.photo.url( :s169 )
|
43
43
|
json.photo_thumb2_url item.report.photo.photo.url( :thumb2 )
|
44
44
|
end
|
45
45
|
|
@@ -51,7 +51,7 @@ json.newsitems do
|
|
51
51
|
json.is_purchased current_user.profile.has_premium_purchase( item.report )
|
52
52
|
end
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
if item.video_id
|
56
56
|
json.partial! 'ishapi/videos/show', :video => Video.unscoped.find( item.video_id )
|
57
57
|
end
|
@@ -60,6 +60,6 @@ json.newsitems do
|
|
60
60
|
json.item_type 'photo'
|
61
61
|
json.partial! 'ishapi/photos/index', :photos => [ item.photo ]
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
end
|
65
65
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
|
2
2
|
#
|
3
3
|
# ishapi / sites / show
|
4
4
|
#
|
@@ -22,7 +22,7 @@ json.cache! key do
|
|
22
22
|
json.partial! 'ishapi/newsitems/index', :newsitems => @newsitems, :resource => @site
|
23
23
|
json.partial! 'ishapi/reports/index', :reports => @reports, :resource => @site
|
24
24
|
json.partial! 'ishapi/videos/index', :videos => @site.videos
|
25
|
-
|
25
|
+
|
26
26
|
json.feature_tags do
|
27
27
|
json.array! @feature_tags do |feature_tag|
|
28
28
|
json.partial! 'ishapi/tags/widget', :tag => feature_tag
|
data/config/routes.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Ishapi::Engine.routes.draw do
|
2
|
-
root :to => '
|
3
|
-
post 'home', :to => '
|
2
|
+
root :to => 'application#home'
|
3
|
+
post 'home', :to => 'application#home'
|
4
4
|
|
5
5
|
resources :addresses
|
6
6
|
|
@@ -15,8 +15,6 @@ Ishapi::Engine.routes.draw do
|
|
15
15
|
namespace :co_tailors do
|
16
16
|
end
|
17
17
|
|
18
|
-
post 'do_purchase', to: 'gameui#do_purchase'
|
19
|
-
|
20
18
|
get 'events/view/:eventname', :to => 'events#show'
|
21
19
|
|
22
20
|
get 'galleries', :to => 'galleries#index'
|
@@ -29,17 +27,20 @@ Ishapi::Engine.routes.draw do
|
|
29
27
|
get 'maps', to: 'maps#index'
|
30
28
|
get 'maps/view/:slug', to: 'maps#show'
|
31
29
|
get 'markers/view/:slug', to: 'maps#show_marker'
|
32
|
-
|
33
|
-
get 'my/newsitems', to: 'newsitems#index'
|
34
|
-
get 'my/account', to: 'user_profiles#my'
|
30
|
+
get "/my/account", to: "my/my#account"
|
35
31
|
namespace :my do
|
36
|
-
|
37
|
-
get 'reports',
|
38
|
-
get
|
39
|
-
post 'videos',
|
32
|
+
get 'newsitems', to: 'newsitems#index'
|
33
|
+
get 'reports', to: 'reports#index'
|
34
|
+
get 'videos', to: 'videos#index'
|
35
|
+
post 'videos', to: 'videos#index'
|
40
36
|
end
|
41
37
|
|
38
|
+
post 'do_purchase', to: 'gameui#do_purchase' # @TODO: rename to just purchase, or destroy endpoint
|
42
39
|
post 'payments', :to => 'payments#create'
|
40
|
+
post 'payments2', :to => 'payments#create2' # @TODO: change
|
41
|
+
get 'payments2', to: 'payments#create2'
|
42
|
+
post 'payments/unlock', to: 'payments#unlock' # do_purchase
|
43
|
+
post 'stripe_confirm', to: 'payments#stripe_confirm' # @TODO: test-drive
|
43
44
|
|
44
45
|
get 'profiles/view/:username', :to => 'user_profiles#show'
|
45
46
|
|
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.134
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -195,7 +195,6 @@ files:
|
|
195
195
|
- app/assets/stylesheets/ishapi/articles.css
|
196
196
|
- app/assets/stylesheets/scaffold.css
|
197
197
|
- app/controllers/ishapi/addresses_controller.rb
|
198
|
-
- app/controllers/ishapi/api_controller.rb
|
199
198
|
- app/controllers/ishapi/application_controller.rb
|
200
199
|
- app/controllers/ishapi/articles_controller.rb
|
201
200
|
- app/controllers/ishapi/cities_controller.rb
|
@@ -249,6 +248,7 @@ files:
|
|
249
248
|
- app/views/ishapi/maps/index.jbuilder
|
250
249
|
- app/views/ishapi/maps/show.jbuilder
|
251
250
|
- app/views/ishapi/measurements/_show.jbuilder
|
251
|
+
- app/views/ishapi/my/my/account.jbuilder
|
252
252
|
- app/views/ishapi/my/videos/index.jbuilder
|
253
253
|
- app/views/ishapi/newsitems/_index.jbuilder
|
254
254
|
- app/views/ishapi/newsitems/index.jbuilder
|
@@ -265,7 +265,6 @@ files:
|
|
265
265
|
- app/views/ishapi/tags/_widget.jbuilder
|
266
266
|
- app/views/ishapi/tags/index.jbuilder
|
267
267
|
- app/views/ishapi/tags/show.jbuilder
|
268
|
-
- app/views/ishapi/user_profiles/my.jbuilder
|
269
268
|
- app/views/ishapi/user_profiles/show.jbuilder
|
270
269
|
- app/views/ishapi/users/_index.jbuilder
|
271
270
|
- app/views/ishapi/users/show.jbuilder
|
@@ -284,7 +283,7 @@ homepage: http://wasya.co
|
|
284
283
|
licenses:
|
285
284
|
- MIT
|
286
285
|
metadata: {}
|
287
|
-
post_install_message:
|
286
|
+
post_install_message:
|
288
287
|
rdoc_options: []
|
289
288
|
require_paths:
|
290
289
|
- lib
|
@@ -300,7 +299,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
300
299
|
version: '0'
|
301
300
|
requirements: []
|
302
301
|
rubygems_version: 3.0.6
|
303
|
-
signing_key:
|
302
|
+
signing_key:
|
304
303
|
specification_version: 4
|
305
304
|
summary: Summary of Ishapi.
|
306
305
|
test_files: []
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require_dependency "ishapi/application_controller"
|
2
|
-
|
3
|
-
module Ishapi
|
4
|
-
class ApiController < UnrestrictedController
|
5
|
-
|
6
|
-
def home
|
7
|
-
authorize! :welcome_home, Ishapi
|
8
|
-
render :json => { :status => :ok, :message => 'Ishapi::ApiController.home',
|
9
|
-
:n_reports => Report.count, :n_cities => City.count }
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|