Class: PasswordResetsController

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

Instance Method Summary collapse

Methods inherited from TbCore::ApplicationController

#not_found

Methods included from TbCore::UserAuthentication

#check_requires_password_change, #current_user, #current_user_id, #current_user_session, #login_path_for_require_user, #require_admin_user, #require_user, #set_time_zone

Methods included from TbCore::Redirection

#back_or_default, #redirect_back_or_default

Methods included from TbCore::ErrorHandling

#class_string, #do_error_response, #handle_record_not_found, #handle_request_error, #handle_unknown_format_error

Instance Method Details

#createObject



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

def create
  @user = SpudUser.find_by(email: params[:email])
  if @user
    @user.reset_perishable_token!
    TbCoreMailer.forgot_password_notification(@user, password_reset_url(@user.perishable_token)).deliver_later
    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



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

def index

end

#showObject



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

def show

end

#updateObject



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

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()
      SpudUserSession.create(@user)
      flash[:notice] = 'Password successfully updated'
      redirect_back_or_default(root_path)
      return
    end
  end
  render 'show'
end