sample_rails_tailwind/app/controllers/password_resets_controller.rb
songtianlun 8bb7615cb1 fix: correct user activation and password reset logic
- Change `user.send(:activate)` to `user.activate` for clarity.
- Fix typo in email parameter from `emial` to `email` in password reset.
- Update render calls to include status codes for better error handling.
- Modify password reset email method to accept a user parameter.
- Update tests to reflect changes in password reset functionality.

These changes improve the clarity of the user activation process and
ensure that the password reset functionality works correctly with
proper error handling and user feedback.
2025-01-08 10:14:36 +08:00

21 lines
476 B
Ruby

class PasswordResetsController < ApplicationController
def new
end
def create
@user = User.find_by(email: params[:password_reset][:email].downcase)
if @user
@user.create_reset_digest
@user.send_password_reset_email
flash[:info] = "Email send with password reset instructions"
redirect_to root_url
else
flash.now[:danger] = "Email not found"
render 'new', status: :unprocessable_entity
end
end
def edit
end
end