Skip to content

Commit

Permalink
Merge pull request #97 from rusikf/fix_devise
Browse files Browse the repository at this point in the history
fix locale on failure auth fixes #41
  • Loading branch information
scott committed Mar 17, 2016
2 parents 562ad57 + f8bf789 commit b7ad8a6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions config/initializers/devise.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.

require 'devise/custom_failure'
Devise.setup do |config|


Expand Down Expand Up @@ -257,6 +259,10 @@
# If you want to use other strategies, that are not supported by Devise, or
# change the failure app, you can configure them inside the config.warden block.
#
config.warden do |manager|
manager.failure_app = CustomFailure
end

# config.warden do |manager|
# manager.intercept_401 = false
# manager.default_strategies(scope: :user).unshift :some_external_strategy
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

root to: "locales#redirect_on_locale"

devise_for :users, skip: [:session, :password, :registration, :confirmation], controllers: { omniauth_callbacks: 'omniauth_callbacks' }
devise_for :users, skip: [:password, :registration, :confirmation], controllers: { omniauth_callbacks: 'omniauth_callbacks' }

localized do

Expand Down
14 changes: 14 additions & 0 deletions lib/devise/custom_failure.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class CustomFailure < Devise::FailureApp
def redirect_url
I18n.locale = params[:locale]
new_user_session_path
end

def respond
if http_auth?
http_auth
else
redirect
end
end
end

0 comments on commit b7ad8a6

Please sign in to comment.