Skip to content

Commit 8ecc6c4

Browse files
committed
Solve bad login issue
1 parent fca01f0 commit 8ecc6c4

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

config/application.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@ class Application < Rails::Application
2424

2525
# Make sure Flash is always present even if api_only=true
2626
config.middleware.use ActionDispatch::Flash
27+
28+
config.autoload_paths << Rails.root.join('lib')
29+
config.eager_load_paths << Rails.root.join('lib')
2730
end
2831
end

config/initializers/devise.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,11 @@
265265
# If you want to use other strategies, that are not supported by Devise, or
266266
# change the failure app, you can configure them inside the config.warden block.
267267
#
268-
# config.warden do |manager|
268+
config.warden do |manager|
269269
# manager.intercept_401 = false
270270
# manager.default_strategies(scope: :user).unshift :some_external_strategy
271-
# end
271+
manager.failure_app = CustomFailureApp
272+
end
272273

273274
# ==> Mountable engine configurations
274275
# When using Devise inside an engine, let's call it `MyEngine`, and this engine

lib/custom_failure_app.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class CustomFailureApp < Devise::FailureApp
2+
def respond
3+
redirect
4+
end
5+
6+
def redirect_url
7+
# Redirect back to the login page with a flash message
8+
new_user_session_path
9+
end
10+
end
11+

0 commit comments

Comments
 (0)