Class: ForgotPasswordPortlet

Inherits:
Portlet
  • Object
show all
Defined in:
app/portlets/forgot_password_portlet.rb

Instance Attribute Summary

Attributes inherited from Portlet

#connect_to_container, #connect_to_page_id, #controller

Instance Method Summary collapse

Methods inherited from Portlet

columns_for_index, default_template, default_template_path, enable_template_editor, form, get_subclass, handler, has_edit_link?, inherited, #inline_options, #instance_name, #portlet_type_name, render_inline, set_default_template_path, #store_errors_in_flash, #store_hash_in_flash, #store_params_in_flash, #type_name, types, #url_for_failure, #url_for_success

Instance Method Details

#renderObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/portlets/forgot_password_portlet.rb', line 6

def render
  flash[:forgot_password] = {}

  return unless request.method == :post
  user = User.find_by_email(params[:email])
  
  unless user
    flash[:forgot_password][:error] = "We were unable to verify your account. Please make sure your email address is accurate."
    return
  end
  
  user.reset_token = generate_reset_token
  if user.save
    flash[:forgot_password][:notice] = "Your password has been sent to #{params[:email]}"
    ForgotPasswordMailer.deliver_reset_password(self.reset_password_url + '?token=' + user.reset_token, user.email)
  end
end