Class: Lines::PasswordResetsController

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

Instance Method Summary collapse

Instance Method Details

#createObject


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

def create
  @user = Lines::User.find_by(email: params[:password_reset][:email].downcase)
  if @user
    @user.create_reset_digest
    @user.send_password_reset_email
  end
  flash[:success] = "Reset instructions have been sent to this email-address, if the user is registered."
  redirect_to root_url
end

#editObject


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

def edit
end

#newObject


11
12
# File 'app/controllers/lines/password_resets_controller.rb', line 11

def new
end

#updateObject


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

def update
  if password_blank?
    flash.now[:error] = "Password can't be blank"
    render 'edit'
  elsif wrong_password_confirmation?
    flash.now[:error] = "Password confirmation does not match."
    render 'edit'
  elsif @user.update_attributes(user_params)
    # deletr reset_digest and reset_sent_at
    @user.update_attributes(reset_digest: nil, reset_sent_at: nil)        
    flash[:success] = "Password has been reset. You can now log in with the new password."
    redirect_to new_session_path
  else
    render 'edit'
  end
end