Reset password token is invalid message is a verification error that occurs when updating the password, and is not a special development error (for which messages are stored in devise.en.yml ).
This check is performed in the devise / passwords_controller # update method. Code below:
# 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) 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) respond_with resource, location: after_resetting_password_path_for(resource) else respond_with resource end end
The line self.resource = resource_class.reset_password_by_token(resource_params) sets the resource.errors object, and the error message associated with reset_password_token is not valid.
Checking the value of resource.errors after this line shows a large hash ending in ... @messages={:reset_password_token=>["is invalid"]}
The devise_error_messages method devise_error_messages reformat this to say: "Reset Password icon is invalid."
To change this message, the password controller must be configured, and the update method changed to have a different hash of the error message.
The steps would be as follows:
1) Configure routes for the password controller
# config/routes.rb devise_for :users, :controllers => { :passwords => "passwords" }
2) Create a customized password controller
3) Configure the update method to change the error message:
# app/controllers/passwords_controller.rb # Include the update method as it is fully, with the following changes in the else block: def update ... if resource.errors.empty? ... else if resource.errors.messages[:reset_password_token] resource.errors.messages.delete(:reset_password_token) resource.errors.messages[:password_reset_link] = ["has already been used"] end respond_with resource end
Read more about Configuring development controllers