Class: PasswordResetsController

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

Instance Method Summary collapse

Methods inherited from Spud::ApplicationController

#not_found

Methods included from Spud::ApplicationHelper

#cache_key_for_spud_collection, #current_site_id, #current_site_name, #tb_page_title

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/password_resets_controller.rb', line 11

def create
  @user = SpudUser.find_by_email(params[:email])
  if @user
    @user.reset_perishable_token!
    CoreMailer.forgot_password_notification(@user, password_reset_url(@user.perishable_token)).deliver
    flash[:notice] = "Password reset instructions have been sent to your email"
    redirect_to 
  else
    flash.now[:error] = "No user was found with that email address"
    render 'index'
  end
end

#indexObject



7
8
9
# File 'app/controllers/password_resets_controller.rb', line 7

def index

end

#showObject



24
25
26
# File 'app/controllers/password_resets_controller.rb', line 24

def show
  
end

#updateObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/password_resets_controller.rb', line 28

def update
  if params[:spud_user][:password].blank?
    @user.errors.add(:password, 'must not be blank')
  else
    @user.password = params[:spud_user][:password]
    @user.password_confirmation = params[:spud_user][:password_confirmation]
    if @user.save()
      flash[:notice] = "Password successfully updated"
      redirect_back_or_default(root_path)
      return
    end
  end
  render 'show'
end