lib/janus/controllers/passwords_controller.rb in janus-0.8.1 vs lib/janus/controllers/passwords_controller.rb in janus-0.9.0

- old
+ new

@@ -13,14 +13,17 @@ def create self.resource = resource_class.find_for_database_authentication(params[resource_name]) if resource resource.generate_reset_password_token! - deliver_reset_password_instructions + deliver_reset_password_instructions(resource) respond_to do |format| - format.html { redirect_to root_url, :notice => t('flash.janus.passwords.create.email_sent') } + format.html do + redirect_to after_sending_reset_password_instructions_url(resource), + :notice => t('flash.janus.passwords.create.email_sent') + end format.any { head :ok } end else respond_to do |format| format.html do @@ -61,23 +64,29 @@ end end # Simple wrapper for Mailer#reset_password_instructions.deliver to # allow customization of the email (eg: to pass additional data). - def deliver_reset_password_instructions + def deliver_reset_password_instructions(resource) mailer_class.reset_password_instructions(resource).deliver end # Either redirects the user to after_password_change_url or to # <tt>params[:return_to]</tt> if present. - def redirect_after_password_change(user, options = {}) + def redirect_after_password_change(resource, options = {}) if params[:return_to].present? redirect_to params[:return_to], options else - redirect_to after_password_change_url(user), options + redirect_to after_password_change_url(resource), options end end - def after_password_change_url(user) + # Where to redirect when the password has been changed. + def after_password_change_url(resource) + root_url + end + + # Where to redirect when the instructions have been sent. + def after_sending_reset_password_instructions_url(resource) root_url end end