Class: Bolt::PasswordResetsController

Inherits:
BoltController show all
Defined in:
app/controllers/bolt/password_resets_controller.rb

Instance Method Summary collapse

Methods inherited from BoltController

#blank, #index

Methods included from ConfigHelper

#bolt_config_dashboard_url, #bolt_config_email_from_address, #bolt_config_hostname, #bolt_config_javascript_includes, #bolt_config_logo, #bolt_config_stylesheet_includes, #bolt_config_website_name

Methods included from BoltHelper

#bolt_check_box, #bolt_check_box_group, #bolt_collection_select, #bolt_date_select, #bolt_datetime_select, #bolt_file_field, #bolt_generate_page_title, #bolt_get_access_level_array, #bolt_get_access_level_text, #bolt_get_full_version_string, #bolt_get_short_version_string, #bolt_get_version_info, #bolt_hidden_field, #bolt_password_field, #bolt_radio_button, #bolt_radio_button_group, #bolt_select, #bolt_show_icon, #bolt_show_row_icon, #bolt_table_cell_link, #bolt_table_cell_no_link, #bolt_text_area, #bolt_text_area_big, #bolt_text_field, #bolt_time_select, #bolt_time_zone_select

Instance Method Details

#createObject



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

def create
  users = Bolt::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_bolt_user_session_url
end

#editObject



31
32
33
# File 'app/controllers/bolt/password_resets_controller.rb', line 31

def edit
  render
end

#updateObject



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

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