bscf-core 0.4.99 → 0.5.0

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: b0455d1f4a5bcc686f33479c012b2bc9ec78ed743de0d101134a0c7a814011d1
4
- data.tar.gz: b5082962af2d1679daf511986d30c6c6f9d3e25c818615c7674b63f64dfae2d8
3
+ metadata.gz: 225894f65a8e151960ff603ac227cc575754eae6ab1c146ee20542091fa129a5
4
+ data.tar.gz: e9f6a8a6f912ef97dcfe6fc718deae1204d26a17a93995abc369604b6fa4aab2
5
5
  SHA512:
6
- metadata.gz: c64b3a1a1d4e87ac64919c8948f5f9acf7c97b2cd0fb0410ef894f13e887ca71490e9bd7f5f7e9978ab55b46316bc701f4a37dcf30d2e47f8eb60e39a2603399
7
- data.tar.gz: ad4848e51ba7b6220417f52f57172df8187bd1a3a70af91a64cb47617c932e771dab61844633bb1fc70dba950adf51126e27332977aaf0261a7d135772e81ee9
6
+ metadata.gz: 3c1d6726242a8153d72662522730397733670e19ace435ac032521bfab747ee559bcdd9ae3a65d8480d80676a22e907b68504b1f2b6a8a1af76107c8da69e2f9
7
+ data.tar.gz: 01ad96461f4a1f3de25e67b6b361079de48411cdb6748ffc9654040fc67db27bdbba1928e572ef1066ee875834ed73e6652154badf7d68a6a413f94624a8376b
@@ -3,8 +3,14 @@ module Bscf
3
3
  class ApplicationController < ActionController::API
4
4
  include Pundit::Authorization
5
5
 
6
+ rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
7
+
6
8
  private
7
9
 
10
+ def user_not_authorized
11
+ render json: { error: "You are not authorized to perform this action." }, status: :unauthorized
12
+ end
13
+
8
14
  def is_authenticated
9
15
  render json: { error: "Not authenticated" }, status: :unauthorized unless current_user
10
16
  end
@@ -0,0 +1,17 @@
1
+ class UserPolicy < ApplicationPolicy
2
+ def index?
3
+ admin?
4
+ end
5
+
6
+ def show?
7
+ admin?
8
+ end
9
+
10
+ def by_role?
11
+ admin?
12
+ end
13
+
14
+ def has_virtual_account?
15
+ true
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ class UserProfilePolicy < ApplicationPolicy
2
+ def show?
3
+ true
4
+ end
5
+
6
+ def update_kyc?
7
+ admin?
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ class UserRolePolicy < ApplicationPolicy
2
+ def assign_driver?
3
+ admin?
4
+ end
5
+ end
@@ -2,6 +2,7 @@ module Bscf
2
2
  module Core
3
3
  class Engine < ::Rails::Engine
4
4
  isolate_namespace Bscf::Core
5
+ config.autoload_paths << File.expand_path("../../app/policies", __dir__)
5
6
  config.generators.api_only = true
6
7
 
7
8
  config.generators do |g|
@@ -1,5 +1,5 @@
1
1
  module Bscf
2
2
  module Core
3
- VERSION = "0.4.99"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bscf-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.99
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Asrat
@@ -331,6 +331,9 @@ files:
331
331
  - app/models/bscf/core/voucher.rb
332
332
  - app/models/bscf/core/wholesaler_product.rb
333
333
  - app/policies/application_policy.rb
334
+ - app/policies/user_policy.rb
335
+ - app/policies/user_profile_policy.rb
336
+ - app/policies/user_role_policy.rb
334
337
  - app/services/bscf/core/gebeta_maps_service.rb
335
338
  - app/services/bscf/core/token_service.rb
336
339
  - app/services/bscf/core/transaction_service.rb