Allow resources with no email field to be recoverable
The current implementation is opinionated about the resource should have
an "email" column on it if it is to be recoverable, which isn't
necessarily the case. For example, developers may decide to pull emails
out into their own model or have some other way of communicating
password resets to their users (e.g. text message)
I'm not sure there's an easy test to put together for this case, as
minitest doesn't make it very easy to stub the "email_changed?" to raise
an error. Happy to look into building another model in the
"test/rails_app" if you want to have this properly tested though? Or for
a nice way to get calls to "email_changed?" to raise; minitest isn't
a test framework I'm overly familiar with :).
As a side note, it would be nice if the Validatable module also took
this into account, I may raise another PR for that.
This comes off the back of comments on this commit:
e641b4b7b9
This commit is contained in:
parent
45fc964470
commit
4a45eb9899
|
@ -28,7 +28,7 @@ module Devise
|
|||
|
||||
included do
|
||||
before_save do
|
||||
if email_changed? || encrypted_password_changed?
|
||||
if (respond_to?(:email_changed?) && email_changed?) || encrypted_password_changed?
|
||||
clear_reset_password_token
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue