开发者

Does anyone know the options for Devises `authenticate_user!`?

开发者 https://www.devze.com 2023-03-19 08:21 出处:网络
Like the title says, I\'m looking for the options for devises automatic class authenticate_user!, specifically, I want it to redirect_to开发者_JAVA技巧 to \'/\' and not \'/users/sign_in\'Do the follow

Like the title says, I'm looking for the options for devises automatic class authenticate_user!, specifically, I want it to redirect_to开发者_JAVA技巧 to '/' and not '/users/sign_in'


Do the following:

In config/initializers/devise.rb:

  config.warden do |manager| 
    manager.failure_app = CustomAuthenticationFailure 
  end

Create a new file called lib/custom_authentication_failure.rb:

  class CustomAuthenticationFailure < Devise::FailureApp 
  protected 
    def redirect_url 
      root_path  #or whatever route in your app that points to '/' 
    end 
  end 

And this to your config/application.rb:

  config.autoload_paths += %W(#{config.root}/lib) 


I think you can find your answer here: Devise Wiki

In particular, I think this should do the trick:

Change default sign in and sign out routes

0

精彩评论

暂无评论...
验证码 换一张
取 消