2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-08-31 18:14:32 +02:00
|
|
|
module DevisePopulatedResource
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
# During a GET /password/edit, the resource is a brand new object.
|
2021-09-16 18:42:18 +02:00
|
|
|
# This method gives access to the actual resource record (if available), complete with email, relationships, etc.
|
|
|
|
#
|
|
|
|
# If the resource can't be found (typically because the reset password token has expired),
|
|
|
|
# returns the default blank record.
|
2021-08-31 18:14:32 +02:00
|
|
|
def populated_resource
|
2021-09-16 18:42:18 +02:00
|
|
|
resource_class.with_reset_password_token(resource.reset_password_token) || resource
|
2021-08-31 18:14:32 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
included do
|
|
|
|
helper_method :populated_resource
|
|
|
|
end
|
|
|
|
end
|