]> cat aescling's git repositories - mastodon.git/commit
Localize with i18n for Devise::FailureApp (#2309)
authoralpaca-tc <alpaca-tc@alpaca.tc>
Tue, 25 Apr 2017 13:06:41 +0000 (22:06 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Tue, 25 Apr 2017 13:06:41 +0000 (15:06 +0200)
commit9317ec8eb185659b687dec2ba84c3f7463d7b61d
tree462b08305a4fa45d07c59e8e47853a74b3cda632
parent1b9447853bb3381bb9f43b60fdd9cab41e92b53c
Localize with i18n for Devise::FailureApp (#2309)

This PR fixes I18n.locale for rake middlewares. Mastodon uses Devise that depends on Warden.
Warden::Manager can be found in rake middleware. It is outside of the controller.

In the case of authentication failed, warden calls throw(:warden). At the time Warden::Manager
delegates request to failure_app to generate response and flash[:alert] after catching it.
Unfortunately, I18n.locale is already reset then because I18n.with_locale is enabled only
inside the controller. If we used I18n.locale=, Devise::FailureApp could get the current locale.
app/controllers/application_controller.rb
app/controllers/concerns/localized.rb
spec/controllers/auth/sessions_controller_spec.rb