Class: Caseadilla::PasswordResetsController

Inherits:
CaseadillaController show all
Defined in:
app/controllers/caseadilla/password_resets_controller.rb

Instance Method Summary collapse

Methods inherited from CaseadillaController

#blank, #index

Methods included from ConfigHelper

#caseadilla_config_dashboard_url, #caseadilla_config_email_from_address, #caseadilla_config_hostname, #caseadilla_config_javascript_includes, #caseadilla_config_logo, #caseadilla_config_stylesheet_includes, #caseadilla_config_website_name

Methods included from CaseadillaHelper

#caseadilla_check_box, #caseadilla_check_box_group, #caseadilla_collection_check_boxes, #caseadilla_collection_select, #caseadilla_color_field, #caseadilla_custom_field, #caseadilla_date_field, #caseadilla_date_select, #caseadilla_datetime_field, #caseadilla_datetime_local_field, #caseadilla_datetime_select, #caseadilla_email_field, #caseadilla_file_field, #caseadilla_format_date, #caseadilla_format_datetime, #caseadilla_format_time, #caseadilla_generate_page_title, #caseadilla_get_access_level_array, #caseadilla_get_access_level_text, #caseadilla_get_footer_string, #caseadilla_get_full_version_string, #caseadilla_get_short_version_string, #caseadilla_hidden_field, #caseadilla_month_field, #caseadilla_no_yes_label, #caseadilla_number_field, #caseadilla_pagination_details, #caseadilla_password_field, #caseadilla_radio_button, #caseadilla_radio_button_group, #caseadilla_range_field, #caseadilla_search_field, #caseadilla_select, #caseadilla_show_icon, #caseadilla_show_row_icon, #caseadilla_sort_link, #caseadilla_table_cell_link, #caseadilla_table_cell_no_link, #caseadilla_telephone_field, #caseadilla_text_area, #caseadilla_text_area_wysiwym, #caseadilla_text_field, #caseadilla_time_field, #caseadilla_time_select, #caseadilla_time_zone_select, #caseadilla_url_field, #caseadilla_week_field, #caseadilla_yes_no_label

Instance Method Details

#createObject


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/caseadilla/password_resets_controller.rb', line 9

def create
  users = Caseadilla::User.where(:email => params[:recover_email]).all

  if users.length > 0
    users.each do |user|
      user.send_password_reset_instructions
    end

    if users.length > 1
      flash[:notice] = "Multiple accounts were found. Emails have been sent to " + params[:recover_email] + " with instructions on how to reset your passwords"
    else
      flash[:notice] = "An email has been sent to " + params[:recover_email] + " with instructions on how to reset your password"
    end
  else
    flash[:warning] = "There is no user with that email"
  end

  redirect_to new_caseadilla_user_session_url
end

#editObject


29
30
31
# File 'app/controllers/caseadilla/password_resets_controller.rb', line 29

def edit
  render
end

#updateObject


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/caseadilla/password_resets_controller.rb', line 33

def update
  
  if params[:caseadilla_user][:password].empty? || params[:caseadilla_user][:password_confirmation].empty?
    flash.now[:warning] = "A field has been left empty"
  else
  
    @reset_user.password = params[:caseadilla_user][:password]
    @reset_user.password_confirmation = params[:caseadilla_user][:password_confirmation]
  
    if @reset_user.save
      flash[:notice] = "Password successfully updated"
      redirect_to new_caseadilla_user_session_url
      return
    end
  end
  
  render :action => :edit
end