活动管理员:重置密码在令牌过期后不显示错误

时间:2016-07-26 12:34:56

标签: ruby-on-rails devise activeadmin reset-password

当我生成通过活动管理员忘记密码发送的重置密码链接时,我能够更改密码并登录仪表板,但当我尝试再次使用相同的链接更改密码时,它什么都不做,并重定向到同一页面。即使我输入空密码,它也没有显示错误。我希望它显示令牌过期的错误

每次提交表单时都会生成相同的日志。

  

AdminUser加载(0.6ms)SELECT“admin_users”。* FROM“admin_users”WHERE“admin_users”。“reset_password_token”='14ad4bc9d075cbb5ed8057c9518848e448e56beab6430ff1d3c7459771a79662'ORDER BY“admin_users”。“id”ASC LIMIT 1 [[“reset_password_token”,“ 14ad4bc9d075cbb5ed8057c9518848e448e56beab6430ff1d3c7459771a79662" ]   method = PUT path = / admin / password format = html controller = ActiveAdmin :: Devise :: PasswordsController action = update status = 200 duration = 606.45 view = 570.88 db = 0.64 time = 2016-07-26 12:25:20 UTC category = web ip = 127.0.0.1 params = {“admin_user”=> {“password”=>“[FILTERED]”,“password_confirmation”=>“[FILTERED]”,“reset_password_token”=>“[已过滤] ]“},”commit“=>”更改密码“}

我不知道为什么我会给200状态。任何想法我应该从哪里开始看?

1 个答案:

答案 0 :(得分:0)

我在update中覆盖了设计Devise::PasswordsController方法并添加了一行来显示错误flash[:error] = resource.errors.full_messages.to_sentence 如果resource.errors.empty?为假,基本上它不显示错误。

这是更新的方法

 # PUT /resource/password
  def update
    self.resource = resource_class.reset_password_by_token(resource_params)
    yield resource if block_given?

    if resource.errors.empty?
      resource.unlock_access! if unlockable?(resource)
      if Devise.sign_in_after_reset_password
        flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
        set_flash_message(:notice, flash_message) if is_flashing_format?
        sign_in(resource_name, resource)
      else
        set_flash_message(:notice, :updated_not_active) if is_flashing_format?
      end
      respond_with resource, location: after_resetting_password_path_for(resource)
    else
      flash[:error] = resource.errors.full_messages.to_sentence
      set_minimum_password_length
      respond_with resource
    end
  end