Class: Kryptonite::PasswordResetsController

Inherits:
KryptoniteController show all
Defined in:
app/controllers/kryptonite/password_resets_controller.rb

Instance Method Summary collapse

Methods inherited from KryptoniteController

#blank, #index

Methods included from ConfigHelper

#kryptonite_config_dashboard_url, #kryptonite_config_email_from_address, #kryptonite_config_hostname, #kryptonite_config_javascript_includes, #kryptonite_config_logo, #kryptonite_config_stylesheet_includes, #kryptonite_config_website_name

Methods included from KryptoniteHelper

#kryptonite_assets_field, #kryptonite_check_box, #kryptonite_check_box_group, #kryptonite_collection_select, #kryptonite_date_select, #kryptonite_datetime_select, #kryptonite_file_field, #kryptonite_generate_page_title, #kryptonite_get_access_level_array, #kryptonite_get_access_level_text, #kryptonite_get_full_version_string, #kryptonite_get_language_array, #kryptonite_get_short_version_string, #kryptonite_get_version_info, #kryptonite_hidden_field, #kryptonite_password_field, #kryptonite_radio_button, #kryptonite_radio_button_group, #kryptonite_select, #kryptonite_show_icon, #kryptonite_show_row_icon, #kryptonite_table_cell_link, #kryptonite_table_cell_no_link, #kryptonite_text_area, #kryptonite_text_area_big, #kryptonite_text_field, #kryptonite_time_select, #kryptonite_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/kryptonite/password_resets_controller.rb', line 11

def create
  users = Kryptonite::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] = t(:multiple_acctounts_notice, :email=>params[:recover_email])
    else
      flash[:notice] = t(:email_sent_notice, :email=>params[:recover_email])
    end
  else
    flash[:warning] = t(:no_user_warning)
  end

  redirect_to new_kryptonite_user_session_url
end

#editObject



31
32
33
# File 'app/controllers/kryptonite/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/kryptonite/password_resets_controller.rb', line 35

def update
  
  if params[:kryptonite_user][:password].empty? || params[:kryptonite_user][:password_confirmation].empty?
    flash.now[:warning] = t(:field_empty_warning)
  else
  
    @reset_user.password = params[:kryptonite_user][:password]
    @reset_user.password_confirmation = params[:kryptonite_user][:password_confirmation]
  
    if @reset_user.save
      flash[:notice] = t(:password_updated_notice)
      redirect_to new_kryptonite_user_session_url
      return
    end
  end
  
  render :action => :edit
end