Class: PasswordResetsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- PasswordResetsController
- Defined in:
- lib/generators/authpro/templates/password_resets_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/generators/authpro/templates/password_resets_controller.rb', line 5 def create user = User.find_by email: params[:email] if user user.prepare_password_reset UserMailer.password_reset(user).deliver redirect_to root_url, notice: "Email sent with password reset instructions." else flash.now.alert = "We could not find anyone with that email address." render "new" end end |
#edit ⇒ Object
18 19 20 |
# File 'lib/generators/authpro/templates/password_resets_controller.rb', line 18 def edit @user = User.find_by! password_reset_token: params[:id] end |
#new ⇒ Object
2 3 |
# File 'lib/generators/authpro/templates/password_resets_controller.rb', line 2 def new end |
#update ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/generators/authpro/templates/password_resets_controller.rb', line 22 def update @user = User.find_by! password_reset_token: params[:id] if @user.password_reset_sent_at < 20.hours.ago redirect_to new_password_reset_path, alert: "Password reset has expired." elsif @user.update_attributes(user_params) redirect_to root_url, notice: "Password has been reset." else render :edit end end |