ishapi 0.1.8.134 → 0.1.8.135
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/README.md +7 -0
- data/app/controllers/ishapi/application_controller.rb +16 -11
- data/app/controllers/ishapi/galleries_controller.rb +2 -1
- data/app/controllers/ishapi/my/galleries_controller.rb +12 -0
- data/app/controllers/ishapi/my/my_controller.rb +0 -6
- data/app/models/ishapi/ability.rb +1 -1
- data/app/views/ishapi/galleries/index.jbuilder +1 -1
- data/config/routes.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d4ac76a945cecc499cbcd7702b5fa87065bbc551b68681871f8dd8e049d7434
|
4
|
+
data.tar.gz: 27faa2c48c19a47d7b46572c4ce3c7ff052737df6840e3ee22d930f65be37752
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 814a536e1e9f406bc707576da08b8265fcb6a72637b97b5ebd077c459943dec930f7172fbdf28469fb59f5d3057d3796f37ff3ad75db312fa9754b6628c5641b
|
7
|
+
data.tar.gz: da987ea35b0a763299fa30997546b3ebbee28229dfef11193f78ba668c1ab195e5742ad4de73fd06346c54a9cd1e698b9d1c1ad40a515c65ad8d669797eaa7fd
|
data/README.md
CHANGED
@@ -1,12 +1,19 @@
|
|
1
1
|
|
2
2
|
# Develop
|
3
3
|
|
4
|
+
-=----- 20201228
|
5
|
+
|
6
|
+
Expects params[:jwtToken]
|
7
|
+
no... expects params[:accessToken]
|
8
|
+
somehow expects params[:jwt_token] ?
|
9
|
+
|
4
10
|
# Test
|
5
11
|
|
6
12
|
cd test/dummy
|
7
13
|
be rspec spec
|
8
14
|
|
9
15
|
# Install
|
16
|
+
|
10
17
|
bundle
|
11
18
|
gem build ishapi.gemspec
|
12
19
|
|
@@ -6,7 +6,7 @@ module Ishapi
|
|
6
6
|
layout :false
|
7
7
|
|
8
8
|
# before_action :check_profile, except: [ :test ]
|
9
|
-
before_action :set_current_ability
|
9
|
+
# before_action :set_current_ability
|
10
10
|
|
11
11
|
check_authorization
|
12
12
|
skip_before_action :verify_authenticity_token
|
@@ -56,6 +56,8 @@ module Ishapi
|
|
56
56
|
private
|
57
57
|
|
58
58
|
def append_long_term_token
|
59
|
+
puts! nil, 'append_long_term_token'
|
60
|
+
|
59
61
|
if @long_term_token
|
60
62
|
response.body = JSON.parse(response.body).merge({ long_term_token: @long_term_token }).to_json
|
61
63
|
end
|
@@ -79,6 +81,7 @@ module Ishapi
|
|
79
81
|
end
|
80
82
|
end
|
81
83
|
end
|
84
|
+
|
82
85
|
## Does not crap out if accessToken is missing
|
83
86
|
def soft_check_long_term_token
|
84
87
|
check_long_term_token soft=true
|
@@ -140,17 +143,9 @@ module Ishapi
|
|
140
143
|
puts! @current_profile, 'current_profile'
|
141
144
|
|
142
145
|
elsif 'jwt' == provider
|
143
|
-
|
144
|
-
|
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
|
146
|
+
decoded = decode(params[:jwt_token])
|
147
|
+
puts! decoded, 'decoded'
|
152
148
|
@current_user = User.find decoded['user_id']
|
153
|
-
|
154
149
|
else
|
155
150
|
puts! 'check_multiprofile(): no access token'
|
156
151
|
raise "ww1 - not implemented"
|
@@ -161,6 +156,8 @@ module Ishapi
|
|
161
156
|
set_current_ability
|
162
157
|
end
|
163
158
|
|
159
|
+
|
160
|
+
|
164
161
|
# same as check_profile but doesn't error out when jwt_token is missing
|
165
162
|
def check_profile_optionally
|
166
163
|
if !params[:jwt_token]
|
@@ -264,6 +261,14 @@ module Ishapi
|
|
264
261
|
puts a.inspect
|
265
262
|
end
|
266
263
|
|
264
|
+
# jwt
|
265
|
+
def check_jwt
|
266
|
+
decoded = decode(params[:jwt_token])
|
267
|
+
puts! decoded, 'decoded'
|
268
|
+
@current_user = User.find decoded['user_id']
|
269
|
+
set_current_ability
|
270
|
+
end
|
271
|
+
|
267
272
|
# jwt
|
268
273
|
def encode(payload, exp = 2.hours.from_now)
|
269
274
|
payload[:exp] = exp.to_i
|
@@ -3,7 +3,8 @@ require_dependency "ishapi/application_controller"
|
|
3
3
|
module Ishapi
|
4
4
|
class GalleriesController < ApplicationController
|
5
5
|
|
6
|
-
before_action :soft_check_long_term_token, only: [ :show ]
|
6
|
+
# before_action :soft_check_long_term_token, only: [ :show ]
|
7
|
+
before_action :check_jwt
|
7
8
|
|
8
9
|
def index
|
9
10
|
@galleries = Gallery.all
|
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
class Ishapi::My::GalleriesController < Ishapi::My::MyController
|
3
|
+
|
4
|
+
## expects params[:jwt_token]
|
5
|
+
def index
|
6
|
+
authorize! :my_index, Gallery
|
7
|
+
@galleries = @current_user.profile.galleries.unscoped.where( is_trash: false ).order_by( created_at: :desc ).limit(20)
|
8
|
+
render 'ishapi/galleries/index'
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
@@ -8,20 +8,14 @@ module Ishapi
|
|
8
8
|
before_action :check_profile
|
9
9
|
|
10
10
|
def account
|
11
|
-
puts! params, 'my account'
|
12
|
-
|
13
11
|
@profile = current_user.profile
|
14
12
|
authorize! :show, @profile
|
15
13
|
end
|
16
14
|
|
17
|
-
|
18
15
|
private
|
19
16
|
|
20
17
|
def do_login
|
21
|
-
puts! params, 'params'
|
22
|
-
|
23
18
|
token = decode(params[:jwtToken])
|
24
|
-
puts! token, 'token'
|
25
19
|
@current_user = User.find(token["user_id"])
|
26
20
|
end
|
27
21
|
|
@@ -3,7 +3,6 @@ class Ishapi::Ability
|
|
3
3
|
include ::CanCan::Ability
|
4
4
|
|
5
5
|
def initialize user
|
6
|
-
|
7
6
|
#
|
8
7
|
# signed in user
|
9
8
|
#
|
@@ -18,6 +17,7 @@ class Ishapi::Ability
|
|
18
17
|
true
|
19
18
|
end
|
20
19
|
|
20
|
+
can [ :my_index ], Gallery
|
21
21
|
can [ :show ], Gallery do |gallery|
|
22
22
|
gallery.user_profile == user.profile
|
23
23
|
end
|
@@ -11,7 +11,7 @@ json.array! @galleries do |gallery|
|
|
11
11
|
json.subhead gallery.subhead
|
12
12
|
json.username gallery.user_profile.name
|
13
13
|
json.cityname gallery.city.name if gallery.city
|
14
|
-
json.
|
14
|
+
json.tag_names gallery.tags.map &:name_seo
|
15
15
|
json.venuename gallery.venue.name if gallery.venue
|
16
16
|
json.partial! 'ishapi/photos/index', :photos => gallery.photos
|
17
17
|
end
|
data/config/routes.rb
CHANGED
@@ -29,6 +29,7 @@ Ishapi::Engine.routes.draw do
|
|
29
29
|
get 'markers/view/:slug', to: 'maps#show_marker'
|
30
30
|
get "/my/account", to: "my/my#account"
|
31
31
|
namespace :my do
|
32
|
+
get 'galleries', to: 'galleries#index'
|
32
33
|
get 'newsitems', to: 'newsitems#index'
|
33
34
|
get 'reports', to: 'reports#index'
|
34
35
|
get 'videos', to: 'videos#index'
|
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.135
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -204,6 +204,7 @@ files:
|
|
204
204
|
- app/controllers/ishapi/invoices_controller.rb
|
205
205
|
- app/controllers/ishapi/maps_controller.rb
|
206
206
|
- app/controllers/ishapi/measurements_controller.rb
|
207
|
+
- app/controllers/ishapi/my/galleries_controller.rb
|
207
208
|
- app/controllers/ishapi/my/my_controller.rb
|
208
209
|
- app/controllers/ishapi/my/reports_controller.rb
|
209
210
|
- app/controllers/ishapi/my/videos_controller.rb
|