kono_utils 1.1.1 → 1.1.2

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: c5015498a44dc1be3efa63b564cc3ad7e0198e40ba2477d1fee1cfaad0bbe97f
4
- data.tar.gz: f23eaa227ce615b319615dbc816e694641c875c9abfeba4d4cdd0d736ebf1783
3
+ metadata.gz: 69e15643bd9d8508138f9934fa1cbc9ab334008f55f143c13ac7dcb08191f82f
4
+ data.tar.gz: e161ae70b8e3c6000a9d7c8e443a801aea5d37f3df5bf2f4bb6a0923082705d1
5
5
  SHA512:
6
- metadata.gz: 667bcd329e9df24bce3836715b866f431fad52f29c63939ca7386e6a8dfc04bd68ead2158310755987d52919f955ef099059a1d15c49571cce90fe9cdbf68f37
7
- data.tar.gz: a12bdf8b96758abcaea4e7e540fb936973936e7f388cbbb1450694cdc4b07b3fe118f42cf245450399c82b6553093dde433cce149701759845678ff8825396fd
6
+ metadata.gz: 6b04eb0bef475dcc2f4852429d5201d0cf496e8f64f5de180c975964f9c011ea5519e82f8693bd0c96abf9e4ff80ab78b786586a14b42b80e7a3c54554c1be7c
7
+ data.tar.gz: 0354353de6c025075200f99f2f61f7ac1edceaea4d06ca47407a3c4eaa1f58eb5267893c7a5d3547989d0d901a2399afce651dd43e61b74168d5cc4ab982897c
@@ -5,7 +5,6 @@ module KonoUtils
5
5
  module BaseEditing
6
6
  extend ActiveSupport::Concern
7
7
 
8
-
9
8
  included do
10
9
 
11
10
  include Pundit
@@ -21,6 +20,8 @@ module KonoUtils
21
20
  helper_method :new_custom_polymorphic_path
22
21
  helper_method :edit_custom_polymorphic_path
23
22
  helper_method :index_custom_polymorphic_path
23
+ helper_method :kono_user
24
+
24
25
  after_action :check_errors, only: [:create, :update], if: -> { ::Rails.env.development? }
25
26
 
26
27
  rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
@@ -148,6 +149,18 @@ module KonoUtils
148
149
  redirect_to(request.referrer || root_path)
149
150
  end
150
151
 
152
+ ##
153
+ # Come per pundit, potrebbe essere il caso in cui l'utente autenticato non è quello standard di device ma uno
154
+ # con modello differente, quindi utilizziamo la stessa configurazione di pundit per avere l'utente da utilizzare
155
+ # nelle authorizzazioni. Centralizziamo questa cosa in questa funzione di modo che possiamo cambiarla in un futuro
156
+ # staccandoci dalle logiche di pundit.
157
+ # @example
158
+ # Sovrascrivere questa funzione restituendo l'utente corretto che viene sottoposto a pundit
159
+ # @return [Object] probabilmente un active-record di tipo User
160
+ def kono_user
161
+ pundit_user
162
+ end
163
+
151
164
  def load_object
152
165
  @object = base_class.find(params[:id])
153
166
  authorize @object
@@ -1,3 +1,3 @@
1
1
  module KonoUtils
2
- VERSION = '1.1.1'
2
+ VERSION = '1.1.2'
3
3
  end
@@ -8,6 +8,8 @@ class ApplicationController < ActionController::Base
8
8
 
9
9
  ##
10
10
  # Semplificazione in sviluppo di un possibile utente
11
+ # come se avessimo installato un devise.
12
+ # Da qua pundit e kono hanno i loro metodi/helper per avere l'informazione dell'utente: pundit_user e kono_user
11
13
  def current_user
12
14
  User.first || User.create(username: 'mario', surname: 'rossi',email:"example@tld.it")
13
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kono_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marino
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-20 00:00:00.000000000 Z
11
+ date: 2021-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview