diff --git a/app/models/user.rb b/app/models/user.rb index 256cfad..56a8f5f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -97,13 +97,17 @@ def average_rating(from:, to:) end def forgot_password! - update( + self.skip_password_validation = true + + update!( password_reset_token: SecureRandom.hex, password_reset_token_expiration: Time.current + 2.hours ) end def eligible_for_password_reset + return false unless password_reset_token_expiration.present? + password_reset_token_expiration > Time.current end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 91a4d0d..f000e8f 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -4,7 +4,7 @@ - + <%= favicon_link_tag 'favicon' %> <%# diff --git a/app/views/passwords/edit.html.erb b/app/views/passwords/edit.html.erb index 8281ff8..f4c901d 100644 --- a/app/views/passwords/edit.html.erb +++ b/app/views/passwords/edit.html.erb @@ -13,7 +13,9 @@
  • Isn't in the <%= link_to 'top 100', 'https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/10_million_password_list_top_100.txt'%> most common passwords
  • - <%= password_field_tag :password, nil, id: "reset_password", data: { rules: "checkLength,checkTop100" } %> +
    + <%= password_field_tag :password, nil, id: "reset_password", data: { rules: "checkLength,checkTop100" } %> +