Class: PasswordsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/rails/generators/rails/authentication/templates/controllers/passwords_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



8
9
10
11
12
13
14
# File 'lib/rails/generators/rails/authentication/templates/controllers/passwords_controller.rb', line 8

def create
  if user = User.find_by(email_address: params[:email_address])
    PasswordsMailer.reset(user).deliver_later
  end

  redirect_to new_session_url, notice: "Password reset instructions sent (if user with that email address exists)."
end

#editObject



16
17
# File 'lib/rails/generators/rails/authentication/templates/controllers/passwords_controller.rb', line 16

def edit
end

#newObject



5
6
# File 'lib/rails/generators/rails/authentication/templates/controllers/passwords_controller.rb', line 5

def new
end

#updateObject



19
20
21
22
23
24
25
# File 'lib/rails/generators/rails/authentication/templates/controllers/passwords_controller.rb', line 19

def update
  if @user.update(params.permit(:password, :password_confirmation))
    redirect_to new_session_url, notice: "Password has been reset."
  else
    redirect_to edit_password_url(params[:token]), alert: "Passwords did not match."
  end
end