首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Active admin:在令牌过期后,重置密码不会显示错误。

Active admin:在令牌过期后,重置密码不会显示错误。
EN

Stack Overflow用户
提问于 2016-07-26 12:34:56
回答 1查看 778关注 0票数 0

当我生成通过active admin发送的重置密码链接时,忘记了密码,我可以更改密码并登录到仪表板上,但是当我再次尝试使用相同的链接更改密码时,它什么也不做,而是重定向到同一个页面。即使我输入空密码,它也不会显示错误。我希望它显示令牌过期的错误。

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

AdminUser Load (0.6ms)从"admin_users“中选择"admin_users".*,其中”admin_users“。”reset_password_token“=按”admin_users“排序。”id“"14ad4bc9d075cbb5ed8057c9518848e448e56beab6430ff1d3c7459771a79662"] method=PUT path=/admin/password 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"=>"FILTERED"},“提交”=>“更改我的密码”}

我不知道为什么我给200个status.Any的想法,我应该开始寻找?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-07-28 06:50:06

我在Devise::PasswordsController中重写了devise Devise::PasswordsController方法,并添加了一行来显示错误-- flash[:error] = resource.errors.full_messages.to_sentence,如果resource.errors.empty?为false,则不会显示错误。

以下是更新的方法

代码语言:javascript
复制
 # 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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38590071

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档