设备忘记密码,未显示Heroku中未找到用户的错误

a1o7rhls  于 2023-04-06  发布在  其他
关注(0)|答案(1)|浏览(149)

我在heroku中部署了一个rails应用程序。
我正在使用devise进行用户身份验证,并且在开发中,如果用户使用忘记密码功能并输入数据库中不存在的电子邮件,则会显示User not found的消息。
但在生产(heroku),在同样的情况下,错误消息不显示,只显示有一个错误,如果你是应用程序的所有者,你应该检查日志.
我检查了日志,它们显示以下消息:

2023-03-30T19:47:06.256967+00:00 heroku[router]: at=info method=GET path="/users/password/new" host=app.orbochile.com request_id=734420d1-6af7-4b37-b069-8e6555c82767 fwd="138.84.34.152" dyno=web.1 connect=0ms service=12ms status=200 bytes=8117 protocol=https
2023-03-30T19:47:18.757588+00:00 heroku[router]: at=info method=POST path="/users/password" host=app.orbochile.com request_id=15f2ef52-0b2e-4ec9-aeb7-1dcfac86ea46 fwd="138.84.34.152" dyno=web.1 connect=0ms service=42ms status=500 bytes=1861 protocol=https
2023-03-30T19:47:18.722934+00:00 app[web.1]: I, [2023-03-30T19:47:18.722857 #2]  INFO -- : [15f2ef52-0b2e-4ec9-aeb7-1dcfac86ea46] Started POST "/users/password" for 138.84.34.152 at 2023-03-30 19:47:18 +0000
2023-03-30T19:47:18.723930+00:00 app[web.1]: I, [2023-03-30T19:47:18.723857 #2]  INFO -- : [15f2ef52-0b2e-4ec9-aeb7-1dcfac86ea46] Processing by Devise::PasswordsController#create as TURBO_STREAM
2023-03-30T19:47:18.743950+00:00 app[web.1]: I, [2023-03-30T19:47:18.743840 #2]  INFO -- : [15f2ef52-0b2e-4ec9-aeb7-1dcfac86ea46]   Parameters: {"authenticity_token"=>"[FILTERED]", "user"=>{"email"=>"probjando@cualquiercosa.cl"}, "commit"=>"Enviarme instrucciones para recuperar clave"}
2023-03-30T19:47:18.756464+00:00 app[web.1]: I, [2023-03-30T19:47:18.756373 #2]  INFO -- : [15f2ef52-0b2e-4ec9-aeb7-1dcfac86ea46] Completed 500 Internal Server Error in 12ms (ActiveRecord: 1.4ms | Allocations: 4392)
2023-03-30T19:47:18.757351+00:00 app[web.1]: F, [2023-03-30T19:47:18.757289 #2] FATAL -- : [15f2ef52-0b2e-4ec9-aeb7-1dcfac86ea46]   
2023-03-30T19:47:18.757353+00:00 app[web.1]: [15f2ef52-0b2e-4ec9-aeb7-1dcfac86ea46] NameError (undefined local variable or method `rendering_options' for #<TurboDeviseController::Responder:0x0000563f5a84d808 @controller=#<Devise::PasswordsController:0x0000000001ff40>, @request=#<ActionDispatch::Request POST "https://app.orbochile.com/users/password" for 138.84.34.152>, @format=:turbo_stream, @resource=#<User id: nil, email: "probjando@cualquiercosa.cl", name: nil, nick_name: nil, phone: nil, city: nil, state: nil, dob: nil, gender: nil, admin: false, created_at: nil, updated_at: nil, category: "Estándar", age: 0, ages: "S/R", last_name: nil, superadmin: false, tester: false, type_user: "Usuario regular">, @resources=[#<User id: nil, email: "probjando@cualquiercosa.cl", name: nil, nick_name: nil, phone: nil, city: nil, state: nil, dob: nil, gender: nil, admin: false, created_at: nil, updated_at: nil, category: "Estándar", age: 0, ages: "S/R", last_name: nil, superadmin: false, tester: false, type_user: "Usuario regular">], @options={}, @action=:new, @default_response=nil>):
2023-03-30T19:47:18.757353+00:00 app[web.1]: [15f2ef52-0b2e-4ec9-aeb7-1dcfac86ea46]   
2023-03-30T19:47:18.757354+00:00 app[web.1]: [15f2ef52-0b2e-4ec9-aeb7-1dcfac86ea46] app/controllers/turbo_devise_controller.rb:9:in `rescue in to_turbo_stream'
2023-03-30T19:47:18.757355+00:00 app[web.1]: [15f2ef52-0b2e-4ec9-aeb7-1dcfac86ea46] app/controllers/turbo_devise_controller.rb:3:in `to_turbo_stream'

我明白,在最后几行它说,有一个errow,因为没有匹配的用户与电子邮件,但我不知道如何使视图显示错误消息的用户,而不是显示消息,该应用程序不工作.
先谢谢你的帮助。
我需要在这种情况下为用户未找到错误显示,而不是检查日志的信息。
编辑

<h2 class="titulo">¿Olvidaste tu clave?</h2>

<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
  <%= render "devise/shared/error_messages", resource: resource %>

  <div class="field">
    <%= f.label :email %><br />
    <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
  </div>
  <br>
  <div class="actions">
    <%= f.submit "Enviarme instrucciones para recuperar clave", class:"btn", id:"boton" %>
  </div>
  
<% end %>

这是我的新密码视图。

m3eecexj

m3eecexj1#

大家好,欢迎来到Stack Overflow。
Devise不向生产中的用户显示“user not found”有一个很好的理由。原因是,如果你显示了这一点,那么恶意用户就可以通过向生产数据库中抛出一大堆常用用户名,并查看哪些用户与真实的用户匹配,哪些用户不匹配,从而找出生产数据库中已经存在的用户。
我强烈建议你不要更新你的系统来给予你所要求的信息。这是严重的信息泄露,是非常令人不快的,这就是为什么devise不向用户显示。
常见的替代方法是说“用户名或密码不匹配,请重试”,用户将重试。

相关问题