mirror of
https://github.com/heartcombo/devise.git
synced 2026-02-19 02:44:31 -05:00
We need to explicitly pass the `locale` around from the options (passed to `warden.authenticate!` for instance) or the `I18n.locale` when logging out and redirecting the user via `throw :warden`, otherwise in a multi-locale app we'd lose the locale previously set / passed around and fallback to the default for that flash message. This is a follow-up of the fixes in #5567 where we implemented the locale passing logic down to the failure app, but it missed these places where we were using `throw :warden`. Closes #5812
25 lines
683 B
Ruby
25 lines
683 B
Ruby
# frozen_string_literal: true
|
|
|
|
# Filters added to this controller apply to all controllers in the application.
|
|
# Likewise, all the methods added will be available for all controllers.
|
|
|
|
class ApplicationController < ActionController::Base
|
|
protect_from_forgery
|
|
around_action :set_locale
|
|
before_action :current_user, unless: :devise_controller?
|
|
before_action :authenticate_user!, if: :devise_controller?
|
|
respond_to(*Mime::SET.map(&:to_sym))
|
|
|
|
devise_group :commenter, contains: [:user, :admin]
|
|
|
|
private
|
|
|
|
def set_locale
|
|
I18n.with_locale(params[:locale] || I18n.default_locale) { yield }
|
|
end
|
|
|
|
def default_url_options
|
|
{locale: params[:locale]}.compact
|
|
end
|
|
end
|