avo 3.32.4 → 3.33.1

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: 0f28594c5b85e9c195d101136003422d6ddc321255474393a02313a54cc0aa86
4
- data.tar.gz: 9e483c35a6ca7cddc0173c63526bed3370d7a81d3d7f356813a98e838c11664e
3
+ metadata.gz: 251f54888bd2cc84f404a0d397b769ab791353f9f2786b3355fbecdc2f258a6c
4
+ data.tar.gz: 74010e8c3b84085a6b52b9b47f396aadeb7beea85b43eeb2f9246a5abe15605d
5
5
  SHA512:
6
- metadata.gz: c5b5123b31107a6acc2456f46d36982af364f665b9593a23cdfc8f45f2edbe32bcc01448dccdbbe406f0c6ae5b3c49bd021e795d2baabbb81cc560228cc84843
7
- data.tar.gz: cb4c91879fb962f4a0267a60e768ff2f49ce915a361201564a4b5325797839dcebf99a8ad9acfa13dd06cbac72ad361916bbc105aa06d8af4ccb15f38e4447d6
6
+ metadata.gz: ca5a2bb0a37b43afeb76fed59e7ace41c2ba8b2e7c8aeb498d404f82dd5bced610bb83c109ad86287f265c6ecd72615612318cb456b4cabe5147e5b391e067de
7
+ data.tar.gz: bda30f213366f943b6cae6c7c7b89a09a249b8001145b52907f7e02b0941e61466b6fc50e2bd3e9d0c9771e44ad6d35dec2710e26661c874e299609c7df8bcbb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (3.32.4)
4
+ avo (3.33.1)
5
5
  actionview (>= 6.1)
6
6
  active_link_to
7
7
  activerecord (>= 6.1)
@@ -223,6 +223,13 @@ module Avo
223
223
 
224
224
  def _authenticate!
225
225
  instance_eval(&Avo.configuration.authenticate)
226
+ return if performed?
227
+
228
+ # `?set_locale=` changes the locale for every user, so only a request the
229
+ # authenticate block let through may store it. Kept here, not in its own
230
+ # callback, so a controller that skips this one cannot store it either.
231
+ locale = available_locale(params[:set_locale])
232
+ Avo.configuration.locale = locale if locale
226
233
  end
227
234
 
228
235
  def render_unauthorized(exception)
@@ -259,21 +266,25 @@ module Avo
259
266
  @resource.form_scope
260
267
  end
261
268
 
262
- # Sets the locale set in avo.rb initializer or if to something that the user set using the `?set_locale=pt-BR` param
269
+ # Sets the locale set in avo.rb initializer or if to something that the user set using the `?set_locale=pt-BR` param.
270
+ # Unknown locales are ignored: I18n.with_locale raises InvalidLocale on them.
263
271
  def set_avo_locale(&action)
264
- locale = Avo.configuration.default_locale
265
-
266
- if params[:set_locale].present?
267
- locale = params[:set_locale]
268
- Avo.configuration.locale = locale
269
- end
272
+ locale = available_locale(params[:set_locale]) || Avo.configuration.default_locale
270
273
 
271
274
  I18n.with_locale(locale, &action)
272
275
  end
273
276
 
274
277
  # Temporary set the locale and reverting at the end of the request.
275
278
  def set_force_locale(&action)
276
- I18n.with_locale(params[:force_locale], &action)
279
+ locale = available_locale(params[:force_locale])
280
+ return yield if locale.nil?
281
+
282
+ I18n.with_locale(locale, &action)
283
+ end
284
+
285
+ def available_locale(value)
286
+ value = value.to_s
287
+ value if value.present? && I18n.locale_available?(value)
277
288
  end
278
289
 
279
290
  def set_sidebar_open
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "3.32.4" unless const_defined?(:VERSION)
2
+ VERSION = "3.33.1" unless const_defined?(:VERSION)
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avo
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.32.4
4
+ version: 3.33.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin