【问题标题】:Disable prepend_before_filter :require_no_authentication for devise passwordcontroller?为设计密码控制器禁用 prepend_before_filter :require_no_authentication?
【发布时间】:2015-12-15 22:30:47
【问题描述】:

我试图覆盖和删除

:设备密码控制器中的require_no_authentication。

class Devise::PasswordsController < DeviseController

  prepend_before_filter :require_no_authentication

与:

class Users::PasswordsController < Devise::PasswordsController

  skip_before_filter :require_no_authentication

但这不起作用,原因是我想使用密码控制器中的编辑方法来拥有自定义逻辑。我想在用户登录时更新密码。

是否有正确的方法来以某种方式禁用此 prepend_before_filter?

【问题讨论】:

    标签: ruby-on-rails devise


    【解决方案1】:

    这几天我一直遇到这个问题。这篇文章解决了他们,我希望它也能帮助你.. https://github.com/plataformatec/devise/issues/2811

    基本上我们需要覆盖 authenticate_your_model!方法,因为有一个检查禁用每个设计控制器的身份验证。所以只需删除 skip_before_filter 并添加一个这样的私有方法:

    private
    
    def authenticate_your_model!(opts={})
      opts[:scope] = :system_manager
      warden.authenticate!(opts) # if !devise_controller? || opts.delete(:force)
    end
    

    【讨论】:

      猜你喜欢
      • 2023-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多