ishapi 0.1.8.143 → 0.1.8.147

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: 021f74439ddc6f123f3f7b33d5d444a27dab186b2ec4a522041eca80667d1e63
4
- data.tar.gz: 5745dcdf642671f2abe7dab138edbd05955c56c05f916388df2f65edb378528d
3
+ metadata.gz: 37a74ed060c1c14807a40188d3cb99e1a7b67910a88dfc8ab4a97ad01f4eb11c
4
+ data.tar.gz: 5c3529a4f9b79117cb4d5c45e92a0d24f4194717f64fe8c2c2f71e3e13543ebb
5
5
  SHA512:
6
- metadata.gz: 713eca65e6c3639a5469bce0a9b8db7d3b204f9a73e414be676ec25a0dcf9f3189d0ed09720be9dccda14533dc0040c6ed546c74649b8180626adeb68fcf4a98
7
- data.tar.gz: 759d8ba2374e9938af198c592ad5eb174e08431146b65956f9c9d79ee8998c0d8d184da41e0606c6955c37dfcda330e55de82fd5feb6c9fa04a2914e50a5b2b7
6
+ metadata.gz: 19ecdf1027c55c91fdc1526fcc7f0fb1d80e47c60d802b01733ab6ba9cd7de0a9eb8f4a31b5dc857758a0f7abf531cebc190c6c8556ae31d20c91e9ad65b5c17
7
+ data.tar.gz: 040f38f5013b4ee85b9385b746a4ce01464613e1c1c2ea315099fc69b7b2fb4d6380dc343e5cf0ad14dc07ca854a000a792182280c3bcaea30fc1c5cf4091bbb
@@ -34,10 +34,10 @@ module Ishapi
34
34
  begin
35
35
  decoded = decode(params[:jwt_token])
36
36
  @current_user = User.find decoded['user_id']
37
- rescue JWT::ExpiredSignature => e
37
+ rescue JWT::ExpiredSignature, JWT::DecodeError => e
38
38
  puts! e, 'ee1'
39
39
  flash[:notice] = 'You arent logged in, or you have been logged out.'
40
- @current_user = User.new
40
+ # @current_user = User.new
41
41
  end
42
42
  end
43
43
 
@@ -8,8 +8,12 @@ module Ishapi
8
8
  before_action :check_profile
9
9
 
10
10
  def account
11
- @profile = current_user.profile
11
+ @profile = current_user&.profile
12
12
  authorize! :show, @profile
13
+ rescue CanCan::AccessDenied
14
+ render json: {
15
+ status: :not_ok,
16
+ }, status: 401
13
17
  end
14
18
 
15
19
  private
@@ -4,6 +4,8 @@ module Ishapi
4
4
  class UsersController < ApplicationController
5
5
  before_action :set_profile, :only => [ :fb_sign_in, :show ]
6
6
 
7
+ skip_authorization_check only: %i| login |
8
+
7
9
  def fb_sign_in
8
10
  authorize! :fb_sign_in, Ishapi
9
11
  # render :json => { :status => :ok }
@@ -14,5 +16,25 @@ module Ishapi
14
16
  authorize! :fb_sign_in, Ishapi
15
17
  end
16
18
 
19
+ def login
20
+ @current_user = User.where( email: params[:email] ).first
21
+ if !@current_user
22
+ render json: { status: :not_ok }, status: 401
23
+ return
24
+ end
25
+ if @current_user.valid_password?(params[:password])
26
+ # from: application_controller#long_term_token
27
+
28
+ # send the jwt to client
29
+ @jwt_token = encode(user_id: @current_user.id.to_s)
30
+ render json: {
31
+ email: @current_user.email,
32
+ jwt_token: @jwt_token,
33
+ long_term_token: @long_term_token,
34
+ n_unlocks: @current_user.profile.n_unlocks,
35
+ }
36
+ end
37
+ end
38
+
17
39
  end
18
40
  end
@@ -14,6 +14,14 @@ json.cache! this_key do
14
14
  json.img_path @map.img_path
15
15
  json.updated_at @map.updated_at
16
16
 
17
+ json.breadcrumbs do
18
+ json.array! @map.breadcrumbs do |b|
19
+ json.name b[:name]
20
+ json.slug b[:slug]
21
+ json.link b[:link]
22
+ end
23
+ end
24
+
17
25
  json.markers do
18
26
  json.array! @markers do |marker|
19
27
  json.name marker.name
@@ -13,8 +13,6 @@ json.cache! key do
13
13
  json.subhead @site.subhead
14
14
  json.description @site.description
15
15
 
16
- json.email @current_user.email
17
-
18
16
  json.is_ads_enabled @site.is_ads_enabled
19
17
  json.play_videos_in_preview @site.play_videos_in_preview
20
18
  json.newsitems_per_page @site.newsitems_per_page
data/config/routes.rb CHANGED
@@ -66,6 +66,7 @@ Ishapi::Engine.routes.draw do
66
66
  post 'users/profile/update', :to => 'users#update'
67
67
  get 'users/profile', :to => 'users#show' # @TODO: only for testing! accessToken must be hidden
68
68
  match 'users/long_term_token', to: 'application#long_term_token', via: [ :get, :post ]
69
+ post 'users/login', to: 'users#login'
69
70
 
70
71
  get 'venues', :to => 'venues#index'
71
72
  get 'venues/view/:venuename', :to => 'venues#show'
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.143
4
+ version: 0.1.8.147
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-15 00:00:00.000000000 Z
11
+ date: 2021-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails