ishapi 0.1.8.162 → 0.1.8.164
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 +57 -57
- data/app/controllers/ishapi/maps_controller.rb +41 -30
- data/app/models/ishapi/ability.rb +31 -24
- data/app/views/ishapi/cities/features.jbuilder +1 -1
- data/app/views/ishapi/cities/index.jbuilder +1 -1
- data/app/views/ishapi/maps/_show.jbuilder +1 -0
- data/app/views/ishapi/maps/show.jbuilder +14 -3
- data/app/views/ishapi/markers/_index.jbuilder +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d090b8c99082a64b9df8d76cdab1f87cf55e4991577486f7f7e8f1b83e7781f
|
4
|
+
data.tar.gz: 7811076deafa69ff6fd3f78503485f30900afd437c50744e8d4433ab4a617d4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e4339fd145e7790912be6d932a741910ebb5358cc717123bd5fd1d10fb72167192c095ff8f18f935c8db0fbfc0108f4c529f1d54669e1bd7adfe63d1f5b73a1
|
7
|
+
data.tar.gz: 64cee7884aabc8e5482f13e61d8f0d77487ae88602267601fb2c91c241c7dd9d5ed82fc38f3d9db4df371b54a372051ca60a563184686df87d460dbe89d842fd
|
@@ -1,73 +1,73 @@
|
|
1
|
-
module Ishapi
|
2
|
-
class ApplicationController < ActionController::Base
|
3
1
|
|
4
|
-
|
5
|
-
def long_term_token
|
6
|
-
accessToken = request.headers[:accessToken]
|
7
|
-
accessToken ||= params[:accessToken]
|
2
|
+
class Ishapi::ApplicationController < ActionController::Base
|
8
3
|
|
9
|
-
|
4
|
+
## POST /api/users/long_term_token , a FB login flow
|
5
|
+
def long_term_token
|
6
|
+
accessToken = request.headers[:accessToken]
|
7
|
+
accessToken ||= params[:accessToken]
|
10
8
|
|
11
|
-
|
12
|
-
"client_id=#{::FB[params['domain']][:app]}&client_secret=#{::FB[params['domain']][:secret]}&" +
|
13
|
-
"fb_exchange_token=#{accessToken}"
|
14
|
-
j = JSON.parse response.body
|
15
|
-
@long_term_token = j['access_token']
|
16
|
-
@graph = Koala::Facebook::API.new( accessToken )
|
17
|
-
@me = @graph.get_object( 'me', :fields => 'email' )
|
18
|
-
@current_user = User.where( :email => @me['email'] ).first
|
9
|
+
params['domain'] = 'tgm.piousbox.com'
|
19
10
|
|
20
|
-
|
21
|
-
|
11
|
+
response = ::HTTParty.get "https://graph.facebook.com/v5.0/oauth/access_token?grant_type=fb_exchange_token&" +
|
12
|
+
"client_id=#{::FB[params['domain']][:app]}&client_secret=#{::FB[params['domain']][:secret]}&" +
|
13
|
+
"fb_exchange_token=#{accessToken}"
|
14
|
+
j = JSON.parse response.body
|
15
|
+
@long_term_token = j['access_token']
|
16
|
+
@graph = Koala::Facebook::API.new( accessToken )
|
17
|
+
@me = @graph.get_object( 'me', :fields => 'email' )
|
18
|
+
@current_user = User.where( :email => @me['email'] ).first
|
22
19
|
|
23
|
-
|
24
|
-
|
25
|
-
jwt_token: @jwt_token,
|
26
|
-
long_term_token: @long_term_token,
|
27
|
-
n_unlocks: @current_user.profile.n_unlocks,
|
28
|
-
}
|
29
|
-
end
|
20
|
+
# send the jwt to client
|
21
|
+
@jwt_token = encode(user_id: @current_user.id.to_s)
|
30
22
|
|
31
|
-
|
23
|
+
render json: {
|
24
|
+
email: @current_user.email,
|
25
|
+
jwt_token: @jwt_token,
|
26
|
+
long_term_token: @long_term_token,
|
27
|
+
n_unlocks: @current_user.profile.n_unlocks,
|
28
|
+
}
|
29
|
+
end
|
32
30
|
|
33
|
-
|
34
|
-
begin
|
35
|
-
decoded = decode(params[:jwt_token])
|
36
|
-
@current_user = User.find decoded['user_id']
|
37
|
-
rescue JWT::ExpiredSignature, JWT::DecodeError => e
|
38
|
-
flash[:notice] = 'You arent logged in, or you have been logged out.'
|
39
|
-
# @current_user = User.new
|
40
|
-
end
|
41
|
-
end
|
31
|
+
private
|
42
32
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
rescue JWT::DecodeError
|
51
|
-
Rails.logger.info("JWT::DecodeError")
|
52
|
-
end
|
53
|
-
current_ability
|
33
|
+
def check_profile
|
34
|
+
begin
|
35
|
+
decoded = decode(params[:jwt_token])
|
36
|
+
@current_user = User.find decoded['user_id']
|
37
|
+
rescue JWT::ExpiredSignature, JWT::DecodeError => e
|
38
|
+
flash[:notice] = 'You are not logged in, or you have been logged out.'
|
39
|
+
# puts! 'You are not logged in, or you have been logged out.'
|
54
40
|
end
|
41
|
+
end
|
55
42
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
43
|
+
# jwt
|
44
|
+
def check_jwt
|
45
|
+
begin
|
46
|
+
decoded = decode(params[:jwt_token])
|
47
|
+
@current_user = User.find decoded['user_id']
|
48
|
+
rescue JWT::ExpiredSignature
|
49
|
+
Rails.logger.info("JWT::ExpiredSignature")
|
50
|
+
rescue JWT::DecodeError
|
51
|
+
Rails.logger.info("JWT::DecodeError")
|
60
52
|
end
|
53
|
+
current_ability
|
54
|
+
end
|
61
55
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
56
|
+
# jwt
|
57
|
+
def decode(token)
|
58
|
+
decoded = JWT.decode(token, Rails.application.secrets.secret_key_base.to_s)[0]
|
59
|
+
HashWithIndifferentAccess.new decoded
|
60
|
+
end
|
67
61
|
|
68
|
-
|
69
|
-
|
70
|
-
|
62
|
+
# jwt
|
63
|
+
def encode(payload, exp = 48.hours.from_now) # @TODO: definitely change, right now I expire once in 2 days.
|
64
|
+
payload[:exp] = exp.to_i
|
65
|
+
JWT.encode(payload, Rails.application.secrets.secret_key_base.to_s)
|
66
|
+
end
|
71
67
|
|
68
|
+
def current_ability
|
69
|
+
@current_ability ||= Ishapi::Ability.new( @current_user )
|
72
70
|
end
|
71
|
+
|
73
72
|
end
|
73
|
+
|
@@ -1,36 +1,47 @@
|
|
1
|
+
|
1
2
|
require_dependency "ishapi/application_controller"
|
2
|
-
module Ishapi
|
3
|
-
class MapsController < ApplicationController
|
4
|
-
before_action :check_profile, only: [ :show ]
|
5
|
-
|
6
|
-
def show
|
7
|
-
@map = ::Gameui::Map.find_by slug: params[:slug]
|
8
|
-
@markers = @map.markers.where( is_active: true )
|
9
|
-
@newsitems = @map.newsitems
|
10
|
-
|
11
|
-
case @map.ordering_type
|
12
|
-
when ::Gameui::Map::ORDERING_TYPE_ALPHABETIC
|
13
|
-
@markers = @markers.order_by( name: :asc )
|
14
|
-
when ::Gameui::Map::ORDERING_TYPE_CUSTOM
|
15
|
-
@markers = @markers.order_by( ordering: :asc )
|
16
|
-
end
|
17
|
-
|
18
|
-
## @TODO: figure this out eventually
|
19
|
-
if city = City.where( cityname: @map.slug ).first
|
20
|
-
# @newsitems = city.newsitems
|
21
|
-
@galleries = city.galleries
|
22
|
-
@reports = city.reports
|
23
|
-
@videos = city.videos
|
24
|
-
end
|
25
|
-
|
26
|
-
authorize! :show, @map
|
27
|
-
end
|
28
3
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
4
|
+
class Ishapi::MapsController < Ishapi::ApplicationController
|
5
|
+
before_action :check_profile, only: [ :show ]
|
6
|
+
|
7
|
+
def show
|
8
|
+
@location = ::Gameui::Map.unscoped.find_by slug: params[:slug]
|
9
|
+
@map = @location.map || @location
|
10
|
+
authorize! :show, @map
|
11
|
+
@newsitems = @map.newsitems
|
12
|
+
|
13
|
+
##
|
14
|
+
## @TODO: absolutely change this!
|
15
|
+
##
|
16
|
+
|
17
|
+
@markers = @map.markers.where( is_active: true )
|
18
|
+
if @current_user
|
19
|
+
a = @current_user.profile.shared_markers.unscoped.where( is_active: true, map_id: @map.id ).to_a
|
20
|
+
@markers = @markers + a
|
33
21
|
end
|
34
22
|
|
23
|
+
# case @map.ordering_type
|
24
|
+
# when ::Gameui::Map::ORDERING_TYPE_ALPHABETIC
|
25
|
+
# @markers = @markers.order_by( name: :asc )
|
26
|
+
# when ::Gameui::Map::ORDERING_TYPE_CUSTOM
|
27
|
+
# @markers = @markers.order_by( ordering: :asc )
|
28
|
+
# end
|
29
|
+
|
30
|
+
# ## @TODO: figure this out eventually
|
31
|
+
# if city = City.where( cityname: @map.slug ).first
|
32
|
+
# # @newsitems = city.newsitems
|
33
|
+
# @galleries = city.galleries
|
34
|
+
# @reports = city.reports
|
35
|
+
# @videos = city.videos
|
36
|
+
# end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
def show_marker
|
41
|
+
@marker = ::Gameui::Marker.find_by slug: params[:slug]
|
42
|
+
authorize! :show, @marker
|
43
|
+
render json: @marker
|
35
44
|
end
|
45
|
+
|
36
46
|
end
|
47
|
+
|
@@ -8,14 +8,9 @@ class Ishapi::Ability
|
|
8
8
|
#
|
9
9
|
unless user.blank?
|
10
10
|
|
11
|
-
if user.profile && user.profile.sudoer?
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
can [ :update ], ::CoTailors::Address do |address|
|
16
|
-
puts [ user.inspect, address.inspect ], '+++ user in cancancan'
|
17
|
-
true
|
18
|
-
end
|
11
|
+
# if user.profile && user.profile.sudoer?
|
12
|
+
# can :manage, :all
|
13
|
+
# end
|
19
14
|
|
20
15
|
can [ :my_index ], Gallery
|
21
16
|
can [ :show ], Gallery do |gallery|
|
@@ -25,7 +20,7 @@ class Ishapi::Ability
|
|
25
20
|
|
26
21
|
can [ :create, :unlock ], ::Ish::Payment
|
27
22
|
|
28
|
-
can [ :buy_stars ], ::
|
23
|
+
can [ :buy_stars ], ::Ish::UserProfile
|
29
24
|
|
30
25
|
end
|
31
26
|
#
|
@@ -33,22 +28,12 @@ class Ishapi::Ability
|
|
33
28
|
#
|
34
29
|
user ||= User.new
|
35
30
|
|
36
|
-
can [ :show ],
|
31
|
+
can [ :show ], Ish::UserProfile
|
37
32
|
|
38
33
|
can [ :index, :show ], City
|
39
34
|
|
40
|
-
can [ :update ], ::CoTailors::Address
|
41
|
-
can [ :add ], ::CoTailors::OrderItem
|
42
|
-
can [ :create, :update_measurements ], ::CoTailors::Order
|
43
|
-
can [ :show ], ::CoTailors::Product
|
44
|
-
|
45
35
|
can [ :index, :show ], Event
|
46
36
|
|
47
|
-
#
|
48
|
-
# Ish::P
|
49
|
-
#
|
50
|
-
|
51
|
-
|
52
37
|
#
|
53
38
|
# G
|
54
39
|
#
|
@@ -56,18 +41,39 @@ class Ishapi::Ability
|
|
56
41
|
can [ :show ], Gallery do |gallery|
|
57
42
|
gallery.is_public && !gallery.is_trash
|
58
43
|
end
|
59
|
-
can [ :index, :show ], ::Gameui::Map
|
60
|
-
can [ :show ], ::Gameui::Marker
|
61
44
|
|
45
|
+
#
|
46
|
+
# I
|
47
|
+
#
|
48
|
+
can [ :fb_sign_in, :long_term_token, :open_permission, :welcome_home ], Ishapi
|
49
|
+
|
50
|
+
#
|
51
|
+
# M
|
52
|
+
#
|
53
|
+
can [ :index ], ::Gameui::Map
|
54
|
+
can [ :show ], ::Gameui::Map do |map|
|
55
|
+
map.is_public || map.shared_profiles.include?( user.profile )
|
56
|
+
end
|
57
|
+
can [ :show ], ::Gameui::Marker do |m|
|
58
|
+
m.is_public
|
59
|
+
end
|
60
|
+
|
61
|
+
#
|
62
|
+
# R
|
63
|
+
#
|
62
64
|
can [ :index ], Report
|
63
65
|
can [ :my_index, :show ], Report do |report|
|
64
66
|
report.is_public
|
65
67
|
end
|
66
68
|
|
67
|
-
|
68
|
-
|
69
|
+
#
|
70
|
+
# S
|
71
|
+
#
|
69
72
|
can [ :index, :show ], Site
|
70
73
|
|
74
|
+
#
|
75
|
+
# T
|
76
|
+
#
|
71
77
|
can [ :index ], Tag
|
72
78
|
can [ :show ], Tag do |tag|
|
73
79
|
tag.is_public
|
@@ -84,5 +90,6 @@ class Ishapi::Ability
|
|
84
90
|
can [ :show ], Video do |video|
|
85
91
|
video.is_public
|
86
92
|
end
|
93
|
+
|
87
94
|
end
|
88
95
|
end
|
@@ -2,7 +2,11 @@
|
|
2
2
|
# ishapi / maps / show
|
3
3
|
#
|
4
4
|
|
5
|
-
this_key = [
|
5
|
+
this_key = [
|
6
|
+
@map.id, @map.updated_at,
|
7
|
+
current_user&.profile&.updated_at,
|
8
|
+
params.permit!
|
9
|
+
]
|
6
10
|
json.cache! this_key do
|
7
11
|
json.map do
|
8
12
|
json.id @map.id.to_s
|
@@ -13,18 +17,25 @@ json.cache! this_key do
|
|
13
17
|
json.h @map.h
|
14
18
|
json.img_path @map.image.image.url(:original)
|
15
19
|
json.updated_at @map.updated_at
|
20
|
+
json.rated @map.rated
|
21
|
+
|
22
|
+
if @map.is_premium
|
23
|
+
json.premium_tier @map.premium_tier
|
24
|
+
json.is_premium @map.premium_tier > 0
|
25
|
+
json.is_purchased current_user&.profile&.has_premium_purchase( @map )
|
26
|
+
end
|
16
27
|
|
17
28
|
if @map.map
|
18
29
|
json.partial! 'ishapi/maps/show', map: @map.map
|
19
30
|
json.config JSON.parse @map.parent.config
|
20
31
|
json.labels JSON.parse @map.parent.labels
|
21
|
-
json.partial! 'ishapi/markers/index',
|
32
|
+
json.partial! 'ishapi/markers/index', markers: @markers
|
22
33
|
else
|
23
34
|
## I removed json parsing from here! _vp_ 2021-10-14
|
24
35
|
## I added json parsing here! _vo_ 2021-10-19
|
25
36
|
json.config JSON.parse @map.config
|
26
37
|
json.labels JSON.parse @map.labels
|
27
|
-
json.partial! 'ishapi/markers/index',
|
38
|
+
json.partial! 'ishapi/markers/index', markers: @markers
|
28
39
|
end
|
29
40
|
|
30
41
|
json.breadcrumbs do
|
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.164
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|