sample_rails_tailwind/app/controllers/password_resets_controller.rb
songtianlun 43d39c3010 feat: add password reset functionality
- Implement PasswordResetsController with new and create actions
- Add views for new and edit password reset forms
- Update routes to include password reset paths
- Create migration to add reset_digest and reset_send_at to users

This commit introduces a complete password reset feature, allowing
users to request a password reset via email. It includes the
necessary controller actions, views, and database schema updates.
The user experience is enhanced with a link to the password reset
form on the login page.
2025-01-07 18:09:44 +08:00

21 lines
445 B
Ruby

class PasswordResetsController < ApplicationController
def new
end
def create
@user = User.find_by(emial: 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'
end
end
def edit
end
end